@@ -22,8 +22,6 @@ static void HideObjects(GameObject[] targets)
2222 {
2323 target . hideFlags = HideFlags . HideInHierarchy ;
2424 }
25-
26- isHiddenObjects = true ;
2725 }
2826
2927 static void DisplayObjects ( GameObject [ ] targets )
@@ -32,29 +30,42 @@ static void DisplayObjects(GameObject[] targets)
3230 {
3331 target . hideFlags = HideFlags . None ;
3432 }
33+ }
3534
36- isHiddenObjects = false ;
35+ static GameObject [ ] getChildObjects ( List < GameObject > targetObjects )
36+ {
37+ // 長過ぎ
38+ GameObject [ ] children = targetObjects
39+ . Select ( targetObject =>
40+ targetObject . transform . Cast < Transform > ( )
41+ . Select ( x => x . gameObject ) . ToArray ( )
42+ )
43+ . SelectMany ( x => x ) . ToArray ( ) ;
44+
45+ return children ;
3746 }
3847
3948 [ MenuItem ( "Tools/Hide Inactive Objects/Enable" ) ]
40- static void ToggleOption ( )
49+ static void Toggle ( )
4150 {
4251 GameObject [ ] allObjects = Resources . FindObjectsOfTypeAll < GameObject > ( ) ;
4352
4453 if ( isHiddenObjects )
4554 {
46- DisplayObjects ( GetInactiveObjects ( enableForWholeHierarchy ? allObjects : targetObjects . ToArray ( ) ) ) ;
55+ DisplayObjects ( GetInactiveObjects ( enableForWholeHierarchy ? allObjects : getChildObjects ( targetObjects ) ) ) ;
4756 }
4857 else
4958 {
50- HideObjects ( GetInactiveObjects ( enableForWholeHierarchy ? allObjects : targetObjects . ToArray ( ) ) ) ;
59+ HideObjects ( GetInactiveObjects ( enableForWholeHierarchy ? allObjects : getChildObjects ( targetObjects ) ) ) ;
5160 }
5261
62+ isHiddenObjects = ! isHiddenObjects ;
63+
5364 Menu . SetChecked ( "Tools/Hide Inactive Objects/Enable" , isHiddenObjects ) ;
5465 }
5566
5667 [ MenuItem ( "Tools/Hide Inactive Objects/Enable" , true ) ]
57- static bool ValidateOption ( )
68+ static bool ValidateToggle ( )
5869 {
5970 Menu . SetChecked ( "Tools/Hide Inactive Objects/Enable" , isHiddenObjects ) ;
6071 return true ;
0 commit comments