public static float SafeGetWidth(this IconBase icon) { try { return(icon.Width); } catch (Exception e) { Debug.LogException(e); Preferences.ForceDisableButton(icon); return(0f); } }
public static string SafeGetName(this IconBase icon) { try { return(icon.Name); } catch (Exception e) { Debug.LogException(e); Preferences.ForceDisableButton(icon); return(string.Empty); } }
public static void SafeDoGUI(this IconBase icon, Rect rect) { try { rect.yMin -= (Preferences.IconsSize - 15) / 2; rect.xMin -= (Preferences.IconsSize - 15) / 2; icon.DoGUI(rect); } catch (Exception e) { Debug.LogException(e); Preferences.ForceDisableButton(icon); } }
private static void ReloadReferences() { referencedObjects.Clear(); try { var count = logEntriesType.InvokeMethod <int>("StartGettingEntries"); for (var i = 0; i < count; i++) { var logEntry = Activator.CreateInstance(logEntryType); var entry = new LogEntry(logEntry); var go = (GameObject)null; logEntriesType.InvokeMethod("GetEntryInternal", i, logEntry); if (entry.Obj) { go = entry.Obj as GameObject; if (!go && entry.Obj is Component) { go = ((Component)entry.Obj).gameObject; } } if (!go) { continue; } if (referencedObjects.ContainsKey(go)) { referencedObjects[go].Add(entry); } else { referencedObjects.Add(go, new List <LogEntry>() { entry }); } } EditorApplication.RepaintHierarchyWindow(); } catch (Exception e) { Debug.LogException(e); Preferences.ForceDisableButton(new Icons.Warnings()); } finally { logEntriesType.InvokeMethod("EndGettingEntries"); } }
static LogEntry() { try { var logEntriesType = typeof(Editor).Assembly.GetType("UnityEditorInternal.LogEntries", false); var logEntryType = typeof(Editor).Assembly.GetType("UnityEditorInternal.LogEntry", false); if (logEntriesType == null) { logEntriesType = typeof(Editor).Assembly.GetType("UnityEditor.LogEntries", false); } if (logEntryType == null) { logEntryType = typeof(Editor).Assembly.GetType("UnityEditor.LogEntry", false); } getEntryMethod = logEntriesType.GetMethod("GetEntryInternal", ReflectionHelper.FullBinding); startMethod = logEntriesType.GetMethod("StartGettingEntries", ReflectionHelper.FullBinding); endMethod = logEntriesType.GetMethod("EndGettingEntries", ReflectionHelper.FullBinding); logEntryConstructor = logEntryType.GetConstructor(new Type[0]); logEntryFields = new Dictionary <string, FieldInfo>(); foreach (var field in logEntryType.GetFields()) { logEntryFields.Add(field.Name, field); } ReloadReferences(); } catch (Exception e) { Debug.LogException(e); Preferences.ForceDisableButton(new Icons.Warnings()); } #if UNITY_5 || UNITY_2017 Application.logMessageReceivedThreaded += (logString, stackTrace, type) => needLogReload = true; #else needLogReload = true; #endif EditorApplication.update += () => { if (needLogReload && Preferences.IsButtonEnabled(new Icons.Warnings()) && Preferences.Enabled) { ReloadReferences(); #if UNITY_5 || UNITY_2017 needLogReload = false; #endif } }; }
private static void ReloadReferences() { if (Preferences.DebugEnabled) { Debug.Log("Reloading Logs References"); } gameObjectEntries.Clear(); compileEntries.Clear(); try { var count = logEntriesType.InvokeStaticMethod <int>("StartGettingEntries"); var nativeEntry = Activator.CreateInstance(logEntryType); for (var i = 0; i < count; i++) { logEntriesType.InvokeStaticMethod("GetEntryInternal", i, nativeEntry); var proxyEntry = new LogEntry(nativeEntry, i); var go = proxyEntry.ObjectReference as GameObject; if (proxyEntry.ObjectReference && !go) { var component = proxyEntry.ObjectReference as Component; if (component) { go = component.gameObject; } } // if(entry.HasMode(EntryMode.ScriptCompileError | EntryMode.ScriptCompileWarning | EntryMode.AssetImportWarning) && entry.ClassType != null) // if(!referencedComponents.Any(e => e.ClassType == entry.ClassType)) if (proxyEntry.ClassType != null) { compileEntries.Add(proxyEntry); } if (go) { if (gameObjectEntries.ContainsKey(go)) { gameObjectEntries[go].Add(proxyEntry); } else { gameObjectEntries.Add(go, new List <LogEntry>() { proxyEntry }); } } } EditorApplication.RepaintHierarchyWindow(); } catch (Exception e) { Debug.LogException(e); Preferences.ForceDisableButton(new Icons.Warnings()); } finally { entriesDirty = false; lastUpdatedTime = EditorApplication.timeSinceStartup; logEntriesType.InvokeStaticMethod("EndGettingEntries"); } }
private static void OnItemGUI(int id, Rect rect) { if (!Preferences.Enabled) { return; } using (ProfilerSample.Get("Enhanced Hierarchy")) try { if (IsGameObject) { foreach (var icon in Preferences.RightIcons.Value) { icon.Init(); } foreach (var icon in Preferences.LeftIcons.Value) { icon.Init(); } Preferences.LeftSideButton.Value.Init(); } SetTitle("EH 2.0"); CalculateIconsWidth(); DoSelection(RawRect); IgnoreLockedSelection(); var trailingWidth = DoTrailing(RawRect); ColorSort(RawRect); DrawTree(RawRect); DrawLeftSideIcons(RawRect); ChildToggle(); DrawTooltip(RawRect, trailingWidth); if (IsGameObject) { rect.xMax -= Preferences.Offset; rect.xMin = rect.xMax; rect.y++; foreach (var icon in Preferences.RightIcons.Value) { try { using (new GUIBackgroundColor(Styles.backgroundColorEnabled)) { rect.xMin -= icon.Width; icon.DoGUI(rect); rect.xMax -= icon.Width; } } catch (Exception e) { Debug.LogException(e); Preferences.ForceDisableButton(icon); } } var leftSideRect = RawRect; try { if (Preferences.LeftmostButton) { leftSideRect.xMin = 0f; } else { leftSideRect.xMin -= 2f + CurrentGameObject.transform.childCount > 0 || Preferences.Tree ? 30f : 18f; } leftSideRect.xMax = leftSideRect.xMin + Preferences.LeftSideButton.Value.Width; using (new GUIBackgroundColor(Styles.backgroundColorEnabled)) Preferences.LeftSideButton.Value.DoGUI(leftSideRect); } catch (Exception e) { Debug.LogException(e); Preferences.ForceDisableButton(Preferences.LeftSideButton.Value); } } DrawMiniLabel(ref rect); DrawHorizontalSeparator(RawRect); } catch (Exception e) { Utility.LogException(e); } }