@@ -20,24 +20,18 @@ namespace UnityHierarchyFolders.Runtime
20
20
/// </summary>
21
21
static class CanDestroyExtension
22
22
{
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 ) ) ;
32
29
33
30
/// <summary>Checks whether the stated component can be destroyed without violating dependencies.</summary>
34
31
/// <returns>Is component destroyable?</returns>
35
32
/// <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 ( ) ) ) ;
41
35
}
42
36
#endif
43
37
@@ -85,15 +79,12 @@ private void HandleSelection()
85
79
}
86
80
}
87
81
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
+ ) ;
97
88
98
89
/// <summary>Delete all components regardless of dependency hierarchy.</summary>
99
90
/// <param name="comps">Which components to delete.</param>
@@ -169,10 +160,11 @@ public void Flatten()
169
160
{
170
161
if ( child . parent == this . transform )
171
162
{
172
- child . name = this . name + '/' + child . name ;
163
+ child . name = $ " { this . name } / { child . name } " ;
173
164
child . parent = this . transform . parent ;
174
165
}
175
166
}
167
+
176
168
if ( Application . isPlaying )
177
169
{
178
170
Destroy ( this . gameObject ) ;
0 commit comments