public static void FilterCurrentStageOrScene(Func <Transform, bool> func, List <Transform> results) { var stage = PrefabStageUtility.GetCurrentPrefabStage(); if (stage != null) { using (var scope = ListPoolScope <Transform> .Create()) { stage.prefabContentsRoot.GetComponentsInChildren(true, scope.list); FilterList(func, scope.list, results); } } else { var count = EditorSceneManager.loadedSceneCount; for (var i = 0; i < count; i++) { FilterScene(EditorSceneManager.GetSceneAt(i), func, results); } if (Application.isPlaying) { // DontDestroyOnLoad Scene var go = new GameObject(); go.hideFlags = HideFlags.HideAndDontSave; GameObject.DontDestroyOnLoad(go); FilterScene(go.scene, func, results); GameObject.DestroyImmediate(go); } } }
public static void FilterCurrentStageOrScene(Func <Transform, bool> func, List <Transform> results) { using (var scope = ListPoolScope <Transform> .Create()) { var stage = PrefabStageUtility.GetCurrentPrefabStage(); if (stage != null) { stage.prefabContentsRoot.transform.GetComponentsInChildren(true, scope.list); } else { var count = EditorSceneManager.loadedSceneCount; for (var i = 0; i < count; i++) { using (var gos = ListPoolScope <GameObject> .Create()) { var scene = EditorSceneManager.GetSceneAt(i); scene.GetRootGameObjects(gos.list); foreach (var go in gos.list) { go.GetComponentsInChildren(true, scope.list); } } } } for (var i = 0; i < scope.list.Count; i++) { if (func(scope.list[i])) { results.Add(scope.list[i]); } } } }
public static bool CheckMissingPropOnTransfrom(Transform trans) { using (var scope = ListPoolScope <Component> .Create()) { trans.GetComponents(scope.list); foreach (var comp in scope.list) { if (comp && UnityUtil.AnyOneProperty(CheckMissingProp, comp)) { return(true); } } } return(false); }
public static bool CheckMissingScriptOnTransfrom(Transform trans) { using (var scope = ListPoolScope <Component> .Create()) { trans.GetComponents(scope.list); foreach (var comp in scope.list) { if (comp == null) { return(true); } } } return(false); }
public static bool AnyOneComponentAndChildren <T>(Func <T, bool> func, Transform root) where T : Component { using (var scope = ListPoolScope <T> .Create()) { root.GetComponentsInChildren(scope.list); for (var i = 0; i < scope.list.Count; i++) { if (func(scope.list[i])) { return(true); } } } return(false); }