private static bool ProcessSelectedScenes(List <IssueRecord> issues) { bool result = true; currentPhase++; for (int i = 0; i < scenesCount; i++) { string scenePath = scenesPaths[i]; string sceneName = Path.GetFileNameWithoutExtension(scenePath); if (EditorUtility.DisplayCancelableProgressBar(string.Format(PROGRESS_CAPTION, currentPhase, phasesCount, i + 1, scenesCount), string.Format("Opening scene: " + Path.GetFileNameWithoutExtension(scenePath)), (float)i / scenesCount)) { result = false; break; } if (CSSceneTools.GetCurrentScenePath() != scenePath) { CSSceneTools.OpenScene(scenePath); } #if UNITY_5_3_PLUS // if we're scanning currently opened scene and going to scan more scenes, // we need to close all additional scenes to avoid duplicates else if (EditorSceneManager.loadedSceneCount > 1 && scenesCount > 1) { CSSceneTools.CloseAllScenesButActive(); } #endif GameObject[] gameObjects = CSEditorTools.GetAllSuitableGameObjectsInCurrentScene(); int objectsCount = gameObjects.Length; for (int j = 0; j < objectsCount; j++) { if (EditorUtility.DisplayCancelableProgressBar(string.Format(PROGRESS_CAPTION, currentPhase, phasesCount, i + 1, scenesCount), string.Format("Processing scene: {0} ... {1}%", sceneName, j * 100 / objectsCount), (float)i / scenesCount)) { result = false; break; } CheckObjectForIssues(issues, scenePath, gameObjects[j], true); } if (!result) { break; } } return(result); }
public void Show() { GameObject[] allObjects; if (location == RecordLocation.Scene) { if (CSSceneTools.GetCurrentScenePath() != path) { if (!CSSceneTools.SaveCurrentSceneIfUserWantsTo()) { return; } CSSceneTools.OpenScene(path); } allObjects = CSEditorTools.GetAllSuitableGameObjectsInCurrentScene(); CSEditorTools.PingObjectDelayed(AssetDatabase.LoadAssetAtPath(path, typeof(Object))); } else { List <GameObject> prefabs = new List <GameObject>(); CSEditorTools.GetAllSuitableGameObjectsInPrefabAssets(prefabs); allObjects = prefabs.ToArray(); } GameObject go = FindObjectInCollection(allObjects); if (go != null) { if (location == RecordLocation.Scene) { Selection.activeTransform = go.transform; } else { Selection.activeGameObject = go; if (gameObjectPath.Split('/').Length > 2) { CSEditorTools.PingObjectDelayed(AssetDatabase.LoadAssetAtPath(path, typeof(Object))); } } } else { MaintainerWindow.ShowNotification("Can't find object " + gameObjectPath); } }
private static bool ScanSceneFiles(List <CleanerRecord> results, bool showProgress = true) { bool canceled = false; currentPhase++; string[] scenesPaths = CSEditorTools.FindAssetsFiltered("t:Scene", MaintainerSettings.Cleaner.pathIgnores); int scenesCount = scenesPaths.Length; for (int i = 0; i < scenesCount; i++) { if (showProgress && EditorUtility.DisplayCancelableProgressBar(string.Format(PROGRESS_CAPTION, currentPhase, phasesCount, i + 1, scenesCount), "Scanning scene files...", (float)i / scenesCount)) { canceled = true; break; } string scenePath = scenesPaths[i]; if (CSSceneTools.GetCurrentScenePath() != scenePath) { CSSceneTools.OpenScene(scenePath); } #if UNITY_5_3_PLUS // if we're scanning currently opened scene and going to scan more scenes, // we need to close all additional scenes to avoid duplicates else if (EditorSceneManager.loadedSceneCount > 1 && scenesCount > 1) { CSSceneTools.CloseAllScenesButActive(); } #endif int objectsInScene = 0; GameObject[] gameObjects = CSEditorTools.GetAllSuitableGameObjectsInCurrentScene(); objectsInScene = gameObjects.Length; if (objectsInScene == 0) { results.Add(AssetRecord.Create(RecordType.EmptyScene, scenePath)); } } return(!canceled); }
private GameObject GetGameObjectWithThisIssue() { GameObject[] allObjects; if (location == RecordLocation.Scene) { allObjects = CSEditorTools.GetAllSuitableGameObjectsInCurrentScene(); } else { List <GameObject> prefabs = new List <GameObject>(); CSEditorTools.GetAllSuitableGameObjectsInPrefabAssets(prefabs); allObjects = prefabs.ToArray(); } return(FindObjectInCollection(allObjects)); }