private void OnGUI() { GUI.depth = -100; //handle assembly reload causing drawer to go null, resulting in null reference exceptions if (drawer == null) { Close(); return; } var preferences = inspector.Preferences; DrawGUI.BeginOnGUI(preferences, true); bool addedComponent = false; EditorGUI.BeginChangeCheck(); { if (drawer.OnGUI(ref addedComponent)) { GUI.changed = true; Repaint(); isDirty = 3; } } if (EditorGUI.EndChangeCheck()) { isDirty = 3; } if (addedComponent) { Close(); return; } if (isDirty > 0) { GUI.changed = true; Repaint(); } var rect = position; rect.x = 0f; rect.y = 0f; DrawGUI.DrawRect(rect, preferences.theme.ComponentSeparatorLine); }
/// <returns> True if should stop receiving OnGUIEvents. </returns> private static bool OnGUIStatic() { if (preferences == null) { #if UNITY_EDITOR if (EditorApplication.isCompiling) { #if DEV_MODE Debug.Log("OnGUIEventHelper - waiting before fetching preferences asset because still compiling scripts..."); #endif return(false); } if (EditorApplication.isUpdating) { #if DEV_MODE Debug.Log("OnGUIEventHelper - waiting before fetching preferences asset because still updating asset database..."); #endif return(false); } #endif try { preferences = InspectorUtility.Preferences; } #if DEV_MODE catch (NullReferenceException e) { Debug.LogWarning("OnGUIEventHelper.OnGUI failed to fetch preferences asset. " + e); #else catch (NullReferenceException) { #endif return(false); } if (preferences == null) { #if DEV_MODE Debug.LogWarning("OnGUIEventHelper.OnGUI failed to find preferences asset."); #endif return(false); } } preferences.Setup(); #if DEV_MODE && DEBUG_IS_STILL_NEEDED Debug.Log(StringUtils.ToColorizedString("EnsureOnGUICallbacks calling BeginOnGUI with isStillNeeded: " + isStillNeeded.Count + ", Event: ", Event.current)); #endif DrawGUI.BeginOnGUI(preferences, true); if (Event.current.type == EventType.Layout) { InspectorManager.Instance().OnLayout(); for (int n = isStillNeeded.Count - 1; n >= 0; n--) { if (isStillNeeded[n]()) { return(false); } } #if DEV_MODE && DEBUG_ENABLED Debug.Log("EnsureOnGUICallbacks closing because all " + isStillNeeded.Count + " isStillNeeded returned false"); #endif return(true); } return(false); }