/// <summary> /// Updates the prefix drawer. /// </summary> protected virtual void UpdatePrefixDrawer() { var selected = Selected; var mouseovered = Mouseovered; const bool unappliedChanges = true; const bool textClipping = false; var unfolded = Unfolded; if (prefixLabelDrawer != null) { prefixLabelDrawer.Dispose(); } labelGuiStyle = DrawGUI.GetFoldoutStyle(selected, mouseovered, unappliedChanges, textClipping); #if UNITY_EDITOR && UNITY_2018_4_OR_NEWER var fontFromStyle = (GUIStyle)"AM MixerHeader2"; #else var fontFromStyle = InspectorPreferences.Styles.LargeLabel; #endif labelGuiStyle.font = fontFromStyle.font; labelGuiStyle.fontStyle = fontFromStyle.fontStyle; labelGuiStyle.fontSize = fontFromStyle.fontSize; if (!labelIdleColorCached) { labelIdleColorCached = true; labelIdleColor = labelGuiStyle.normal.textColor; } else { SetLabelGUIStyleColor(labelIdleColor); } labelRequiredWidth = labelGuiStyle.CalcSize(label).x + 6f; prefixLabelDrawer = PrefixDrawer.CreateFoldout(label, unfolded, textClipping, labelGuiStyle); }
private void OnValidate() { if (onValidateInProgress) { return; } onValidateInProgress = true; var isBeingEdited = Platform.EditorMode && InspectorUtility.ActiveManager != null && InspectorUtility.ActiveManager.ActiveInspector != null && InspectorUtility.ActiveManager.ActiveInspector.State.drawers.First() != null && Array.IndexOf(InspectorUtility.ActiveManager.ActiveInspector.State.drawers.First().GetValues(), this) != -1; #if DEV_MODE && DEBUG_ON_VALIDATE Debug.Log("InspectorPreferences.OnValidate called with isBeingEdited=" + StringUtils.ToColorizedString(isBeingEdited)); #endif if (isBeingEdited) { isFirstOnValidate = false; //If Setup hasn't been called yet this can be null if (theme != null && DrawGUI.prefixLabelMouseovered != null) { var mouseoverColor = mouseoverEffects.prefixLabelTint ? theme.PrefixMouseoveredText : theme.PrefixIdleText; DrawGUI.prefixLabelMouseovered.SetAllTextColors(mouseoverColor); DrawGUI.prefixLabelMouseoveredModified.SetAllTextColors(mouseoverColor); DrawGUI.foldoutStyleMouseovered.SetAllTextColors(mouseoverColor); DrawGUI.foldoutStyleSelectedMouseovered.SetAllTextColors(mouseoverColor); PrefixDrawer.ClearCache(); // This was happening when the themes field was edited if (theme.guiSkin == null) { #if DEV_MODE Debug.LogError("InspectorPreferences.OnValidate - guiSkin of theme \"" + theme.Name + "\" was null!"); #endif return; } Styles = new InspectorStyles(theme.guiSkin); } themes.OnValidate(); if (onSettingsChanged != null) { onSettingsChanged(this); } } else { if (isFirstOnValidate) { isFirstOnValidate = false; #if !DISABLE_UPDATES && UNITY_EDITOR EditorApplication.delayCall += ApplyRelevantUpdates; #endif } } onValidateInProgress = false; }