diff --git a/HierarchyDecorator/Scripts/Editor/Data/GlobalData.cs b/HierarchyDecorator/Scripts/Editor/Data/GlobalData.cs index 8312c3d..2ae0808 100644 --- a/HierarchyDecorator/Scripts/Editor/Data/GlobalData.cs +++ b/HierarchyDecorator/Scripts/Editor/Data/GlobalData.cs @@ -30,6 +30,8 @@ public class GlobalData // Toggles public bool showActiveToggles = true; + public enum ToggleType {Checkbox, Dot} + public ToggleType activeToggleType = ToggleType.Checkbox; [Tooltip("Clicking and dragging over check boxes to toggle them.")] public bool activeSwiping = true; diff --git a/HierarchyDecorator/Scripts/Editor/Hierarchy/Drawers/ToggleDrawer.cs b/HierarchyDecorator/Scripts/Editor/Hierarchy/Drawers/ToggleDrawer.cs index 9a0bc45..1b2c553 100644 --- a/HierarchyDecorator/Scripts/Editor/Hierarchy/Drawers/ToggleDrawer.cs +++ b/HierarchyDecorator/Scripts/Editor/Hierarchy/Drawers/ToggleDrawer.cs @@ -17,6 +17,10 @@ public class ToggleDrawer : HierarchyDrawer private bool isHoldingMouse = false; private bool isPressingShift = false; + // --- Toggle + + private GUIStyle currentToggleOnStyle, currentToggleOffStyle; + // Target data for settings based off the first instance selected private GameObject targetInstance = null; @@ -68,10 +72,10 @@ protected override void DrawInternal(Rect rect, HierarchyItem item, Settings set // Draw toggles - DrawToggles (rect, instance, !settings.globalData.activeSwiping); + DrawToggles (rect, instance, settings.globalData.activeToggleType, !settings.globalData.activeSwiping); } - private void DrawToggles(Rect rect, GameObject instance, bool canUpdate = true) + private void DrawToggles(Rect rect, GameObject instance, GlobalData.ToggleType toggleType, bool canUpdate = true) { bool isActive = instance.activeSelf; @@ -80,7 +84,28 @@ private void DrawToggles(Rect rect, GameObject instance, bool canUpdate = true) EditorGUI.BeginChangeCheck (); { #if UNITY_2019_1_OR_NEWER - isActive = EditorGUI.Toggle (rect, isActive, isActive ? Style.Toggle : Style.ToggleMixed); + switch (toggleType) + { + case GlobalData.ToggleType.Checkbox: + _RecreateStyleIfNeeded(Style.Toggle, Style.ToggleMixed); + isActive = EditorGUI.Toggle(rect, isActive, isActive ? currentToggleOnStyle : currentToggleOffStyle); + break; + case GlobalData.ToggleType.Dot: + _RecreateStyleIfNeeded(Style.ToggleDot, Style.ToggleDot); + var color = GUI.color; + if (!isActive) + GUI.color = new Color(GUI.color.r, GUI.color.g, GUI.color.b, 0.15f); + isActive = EditorGUI.Toggle(rect, isActive, isActive ? currentToggleOnStyle : currentToggleOffStyle); + GUI.color = color; + break; + } + void _RecreateStyleIfNeeded(GUIStyle on, GUIStyle off) + { + if (currentToggleOnStyle == null || currentToggleOnStyle.name != on.name) + currentToggleOnStyle = new GUIStyle(on); + if (currentToggleOffStyle == null || currentToggleOffStyle.name != off.name) + currentToggleOffStyle = new GUIStyle(off); + } #else isActive = EditorGUI.Toggle (rect, isActive); #endif diff --git a/HierarchyDecorator/Scripts/Editor/Style.cs b/HierarchyDecorator/Scripts/Editor/Style.cs index 0e71839..a9f76f7 100644 --- a/HierarchyDecorator/Scripts/Editor/Style.cs +++ b/HierarchyDecorator/Scripts/Editor/Style.cs @@ -35,7 +35,7 @@ internal static class Style // --- Hierarchy Styles - public static readonly GUIStyle Toggle; + public static readonly GUIStyle Toggle, ToggleDot; public static readonly GUIStyle ToggleMixed; // --- Fields @@ -196,7 +196,15 @@ static Style() }; // Hierarchy Styles - + ToggleDot = new GUIStyle(GUI.skin.button) + { + name = "toggle-dot", // require as unique id for recreate + normal = + { + textColor = EditorStyles.label.normal.textColor, + background = EditorGUIUtility.Load("DotFill") as Texture2D, + }, + }; Toggle = new GUIStyle ("OL Toggle") { normal = diff --git a/HierarchyDecorator/Scripts/Editor/Tabs/GeneralTab.cs b/HierarchyDecorator/Scripts/Editor/Tabs/GeneralTab.cs index a71f4fd..1ccaa73 100644 --- a/HierarchyDecorator/Scripts/Editor/Tabs/GeneralTab.cs +++ b/HierarchyDecorator/Scripts/Editor/Tabs/GeneralTab.cs @@ -14,7 +14,7 @@ public GeneralTab(Settings settings, SerializedObject serializedSettings) : base // --- General Features CreateDrawableGroup("Toggles") - .RegisterSerializedProperty(serializedTab, "showActiveToggles", "activeSwiping", "swipeSameState", "swipeSelectionOnly", "depthMode"); + .RegisterSerializedProperty(serializedTab, "showActiveToggles", "activeToggleType", "activeSwiping", "swipeSameState", "swipeSelectionOnly", "depthMode"); // --- Layers diff --git a/HierarchyDecorator/Scripts/Editor/Tabs/StyleTab.cs b/HierarchyDecorator/Scripts/Editor/Tabs/StyleTab.cs index 63b6355..927caca 100644 --- a/HierarchyDecorator/Scripts/Editor/Tabs/StyleTab.cs +++ b/HierarchyDecorator/Scripts/Editor/Tabs/StyleTab.cs @@ -3,7 +3,6 @@ using UnityEngine; using UnityEditor; using UnityEditorInternal; -using static UnityEngine.GraphicsBuffer; namespace HierarchyDecorator {