Skip to content

Commit 369b32c

Browse files
committedApr 8, 2019
Use shorthand syntax where possible
1 parent 67acbb2 commit 369b32c

File tree

2 files changed

+17
-25
lines changed

2 files changed

+17
-25
lines changed
 

‎Editor/FolderEditorUtils.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public static void AddFolderPrefab(MenuCommand command)
2626

2727
public class FolderOnBuild : IProcessSceneWithReport
2828
{
29-
public int callbackOrder { get { return 0; } }
29+
public int callbackOrder { get => 0; }
3030

3131
public void OnProcessScene(Scene scene, BuildReport report)
3232
{

‎Runtime/Folder.cs

+16-24
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,18 @@ namespace UnityHierarchyFolders.Runtime
2020
/// </summary>
2121
static class CanDestroyExtension
2222
{
23-
private static bool Requires(Type obj, Type req)
24-
{
25-
return Attribute.IsDefined(obj, typeof(RequireComponent)) &&
26-
Attribute.GetCustomAttributes(obj, typeof(RequireComponent))
27-
.OfType<RequireComponent>()
28-
// RequireComponent has up to 3 required types per requireComponent, because of course.
29-
.SelectMany(rc => new Type[] { rc.m_Type0, rc.m_Type1, rc.m_Type2 })
30-
.Any(t => t != null && t.IsAssignableFrom(req));
31-
}
23+
private static bool Requires(Type obj, Type req) => Attribute.IsDefined(obj, typeof(RequireComponent)) &&
24+
Attribute.GetCustomAttributes(obj, typeof(RequireComponent))
25+
.OfType<RequireComponent>()
26+
// RequireComponent has up to 3 required types per requireComponent, because of course.
27+
.SelectMany(rc => new Type[] { rc.m_Type0, rc.m_Type1, rc.m_Type2 })
28+
.Any(t => t != null && t.IsAssignableFrom(req));
3229

3330
/// <summary>Checks whether the stated component can be destroyed without violating dependencies.</summary>
3431
/// <returns>Is component destroyable?</returns>
3532
/// <param name="t">Component candidate for destruction.</param>
36-
internal static bool CanDestroy(this Component t)
37-
{
38-
return !t.gameObject.GetComponents<Component>()
39-
.Any(c => Requires(c.GetType(), t.GetType()));
40-
}
33+
internal static bool CanDestroy(this Component t) => !t.gameObject.GetComponents<Component>()
34+
.Any(c => Requires(c.GetType(), t.GetType()));
4135
}
4236
#endif
4337

@@ -85,15 +79,12 @@ private void HandleSelection()
8579
}
8680
}
8781

88-
private bool AskDelete()
89-
{
90-
return EditorUtility.DisplayDialog(
91-
title: "Can't add script",
92-
message: "Folders shouldn't be used with other components. Which component should be kept?",
93-
ok: "Folder",
94-
cancel: "Component"
95-
);
96-
}
82+
private bool AskDelete() => EditorUtility.DisplayDialog(
83+
title: "Can't add script",
84+
message: "Folders shouldn't be used with other components. Which component should be kept?",
85+
ok: "Folder",
86+
cancel: "Component"
87+
);
9788

9889
/// <summary>Delete all components regardless of dependency hierarchy.</summary>
9990
/// <param name="comps">Which components to delete.</param>
@@ -169,10 +160,11 @@ public void Flatten()
169160
{
170161
if (child.parent == this.transform)
171162
{
172-
child.name = this.name + '/' + child.name;
163+
child.name = $"{this.name}/{child.name}";
173164
child.parent = this.transform.parent;
174165
}
175166
}
167+
176168
if (Application.isPlaying)
177169
{
178170
Destroy(this.gameObject);

0 commit comments

Comments
 (0)
Please sign in to comment.