|
4 | 4 | using UnityEditor; |
5 | 5 | using UnityEngine; |
6 | 6 |
|
7 | | -public class HideInactiveObjects : EditorWindow |
| 7 | +namespace jp.kyre.hideInactiveObjects |
8 | 8 | { |
9 | | - private static bool isHiddenObjects = false; |
10 | | - private static bool enableForWholeHierarchy = true; |
11 | | - private static List<GameObject> targetObjects = new List<GameObject>(); |
12 | | - |
13 | | - static GameObject[] GetInactiveObjects(GameObject[] allObjects) |
| 9 | + public class Main : EditorWindow |
14 | 10 | { |
15 | | - GameObject[] inactiveObjects = Array.FindAll(allObjects, x => (!x.activeInHierarchy && !x.activeSelf && x.name != "InternalIdentityTransform")); |
16 | | - return inactiveObjects; |
17 | | - } |
| 11 | + private static bool isHiddenObjects = false; |
| 12 | + private static bool enableForWholeHierarchy = true; |
| 13 | + private static List<GameObject> targetObjects = new List<GameObject>(); |
| 14 | + |
| 15 | + static GameObject[] GetInactiveObjects(GameObject[] allObjects) |
| 16 | + { |
| 17 | + GameObject[] inactiveObjects = Array.FindAll(allObjects, x => (!x.activeInHierarchy && !x.activeSelf && x.name != "InternalIdentityTransform")); |
| 18 | + return inactiveObjects; |
| 19 | + } |
18 | 20 |
|
19 | | - static void HideObjects(GameObject[] targets) |
20 | | - { |
21 | | - foreach (var target in targets) |
| 21 | + static void HideObjects(GameObject[] targets) |
22 | 22 | { |
23 | | - target.hideFlags = HideFlags.HideInHierarchy; |
| 23 | + foreach (var target in targets) |
| 24 | + { |
| 25 | + target.hideFlags = HideFlags.HideInHierarchy; |
| 26 | + } |
24 | 27 | } |
25 | | - } |
26 | 28 |
|
27 | | - static void DisplayObjects(GameObject[] targets) |
28 | | - { |
29 | | - foreach (var target in targets) |
| 29 | + static void DisplayObjects(GameObject[] targets) |
30 | 30 | { |
31 | | - target.hideFlags = HideFlags.None; |
| 31 | + foreach (var target in targets) |
| 32 | + { |
| 33 | + target.hideFlags = HideFlags.None; |
| 34 | + } |
32 | 35 | } |
33 | | - } |
34 | 36 |
|
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(); |
| 37 | + static GameObject[] getChildObjects(List<GameObject> targetObjects) |
| 38 | + { |
| 39 | + // 長過ぎ |
| 40 | + GameObject[] children = targetObjects |
| 41 | + .Select(targetObject => |
| 42 | + targetObject.transform.Cast<Transform>() |
| 43 | + .Select(x => x.gameObject).ToArray() |
| 44 | + ) |
| 45 | + .SelectMany(x => x).ToArray(); |
44 | 46 |
|
45 | | - return children; |
46 | | - } |
| 47 | + return children; |
| 48 | + } |
47 | 49 |
|
48 | 50 | [MenuItem("Tools/Hide Inactive Objects/Enable")] |
49 | 51 | static void Toggle() |
@@ -74,7 +76,7 @@ static bool ValidateToggle() |
74 | 76 | [MenuItem("Tools/Hide Inactive Objects/Options")] |
75 | 77 | public static void ShowWindow() |
76 | 78 | { |
77 | | - GetWindow<HideInactiveObjects>("Hide Inactive Objects"); |
| 79 | + GetWindow<Main>("Hide Inactive Objects"); |
78 | 80 | } |
79 | 81 |
|
80 | 82 | bool showError = false; |
@@ -116,4 +118,6 @@ private void OnGUI() |
116 | 118 |
|
117 | 119 | if (showError) GUILayout.Label("Error: Object を指定するか Hierarchy 全体に設定を有効化してください", new GUIStyle() {normal = new GUIStyleState() { textColor = Color.red }}); |
118 | 120 | } |
| 121 | + } |
| 122 | + |
119 | 123 | } |
0 commit comments