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; } }
private static void OnItemGUI(int instanceID, Rect rect) { if (!_isEnabled) { return; } var instance = EditorUtility.InstanceIDToObject(instanceID) as GameObject; if (instance == null) { return; } var diagnostic = PrefabsAnalysis.Execute(instance); if (diagnostic.Severity != DiagnosticSeverity.None) { diagnostic.Draw(rect); return; } var children = instance.Children(); for (var i = 0; i < children.Count; i++) { var childDiagnostic = PrefabsAnalysis.Execute(children[i]); if (childDiagnostic.Severity == DiagnosticSeverity.None) { continue; } if (childDiagnostic.Severity > diagnostic.Severity) { diagnostic = childDiagnostic; } } diagnostic.AsTransparent().Draw(rect); }
private static void OnUpdate() { if (DateTime.Now - _updateTime < UpdateDelay) { return; } #if UNITY_EDITOR_WIN // Here we check active window pointer, that is related to the current thread messages queue. // So it's probably equal to zero if we don't focused Unity. if (GetActiveWindow() == IntPtr.Zero) { return; } // user32.dll function GetKeyboardState in result byte array do not distinguish right- and left-controls. // So even if real pressed keys count is 2 (LControl + Return), the actual number will be 3 (2 + Control). if (!IsPressed(VirtualKey.Control, VirtualKey.LControl, VirtualKey.Return)) { return; } var gameObject = Selection.activeGameObject; if (gameObject == null) { return; } var diagnostic = PrefabsAnalysis.Execute(gameObject); if (diagnostic == Diagnostic.None) { return; } _updateTime = DateTime.Now; ApplyFix(gameObject); #endif }