Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions HierarchyDecorator/Scripts/Editor/Data/GlobalData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand All @@ -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
Expand Down
12 changes: 10 additions & 2 deletions HierarchyDecorator/Scripts/Editor/Style.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 =
Expand Down
2 changes: 1 addition & 1 deletion HierarchyDecorator/Scripts/Editor/Tabs/GeneralTab.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 0 additions & 1 deletion HierarchyDecorator/Scripts/Editor/Tabs/StyleTab.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using UnityEngine;
using UnityEditor;
using UnityEditorInternal;
using static UnityEngine.GraphicsBuffer;

namespace HierarchyDecorator
{
Expand Down