private static void OnHierarchyWindowChange() { // EditorApplication.hierarchyWindowChanged is called two times in a row after CTRL + D. if (DateTime.Now - _resetTime < ResetDelay) { return; } _resetTime = DateTime.Now; PrefabsAnalysis.Reset(); }
public static void Benchmark() { var gameObjects = SceneManager .GetActiveScene() .GetRootGameObjects() .SelectMany(x => x.RootWithChildren()) .ToList(); PrefabsAnalysis.Reset(); using (SimpleWatch.New(ms => Debug.Log($"Analysis finished in {ms} ms."))) foreach (var gameObject in gameObjects) { PrefabsAnalysis.Execute(gameObject); } }
private static void OnUpdate() { var active = Selection.activeGameObject; if (active == null) { return; } PrefabsAnalysis.Reset(active); var diagnostic = PrefabsAnalysis.Execute(active); if (diagnostic.Id != _diagnostic.Id) { EditorUtility.SetDirty(active); _diagnostic = diagnostic; } }
public static void Enable() { if (_isEnabled) { return; } PrefabsAnalysis.Reset(); EditorApplication.update += OnUpdate; EditorApplication.RepaintHierarchyWindow(); EditorApplication.hierarchyWindowItemOnGUI += OnItemGUI; EditorApplication.hierarchyChanged += OnHierarchyWindowChange; Selection.selectionChanged += OnSelectionChange; _isEnabled = true; }