5
5
using UnityEngine ;
6
6
using Object = UnityEngine . Object ;
7
7
8
- namespace UnityToolbag
8
+ namespace SubjectNerd . QuickToggle
9
9
{
10
10
[ InitializeOnLoad ]
11
11
public class QuickToggle
@@ -14,10 +14,14 @@ public class QuickToggle
14
14
private const string PrefKeyShowToggle = "UnityToolbag.QuickToggle.Visible" ;
15
15
private const string PrefKeyShowDividers = "UnityToolbag.QuickToggle.Dividers" ;
16
16
private const string PrefKeyShowIcons = "UnityToolbag.QuickToggle.Icons" ;
17
+ private const string PrefKeyGutterLevel = "UnityToolbag.QuickToggle.Gutter" ;
17
18
18
19
private const string MENU_NAME = "Window/Hierarchy Quick Toggle/Show Toggles" ;
19
20
private const string MENU_DIVIDER = "Window/Hierarchy Quick Toggle/Dividers" ;
20
21
private const string MENU_ICONS = "Window/Hierarchy Quick Toggle/Object Icons" ;
22
+ private const string MENU_GUTTER_0 = "Window/Hierarchy Quick Toggle/Right Gutter/0" ;
23
+ private const string MENU_GUTTER_1 = "Window/Hierarchy Quick Toggle/Right Gutter/1" ;
24
+ private const string MENU_GUTTER_2 = "Window/Hierarchy Quick Toggle/Right Gutter/2" ;
21
25
#endregion
22
26
23
27
private static readonly Type HierarchyWindowType ;
@@ -45,6 +49,10 @@ private static bool SetupMenuCheckMarks()
45
49
Menu . SetChecked ( MENU_NAME , EditorPrefs . GetBool ( PrefKeyShowToggle ) ) ;
46
50
Menu . SetChecked ( MENU_DIVIDER , EditorPrefs . GetBool ( PrefKeyShowDividers ) ) ;
47
51
Menu . SetChecked ( MENU_ICONS , EditorPrefs . GetBool ( PrefKeyShowIcons ) ) ;
52
+
53
+ int gutterLevel = EditorPrefs . GetInt ( PrefKeyGutterLevel , 0 ) ;
54
+ gutterCount = gutterLevel ;
55
+ UpdateGutterMenu ( gutterCount ) ;
48
56
return true ;
49
57
}
50
58
@@ -63,11 +71,51 @@ private static void ToggleIcons()
63
71
private static void ToggleSettings ( string prefKey , string menuString , out bool valueBool )
64
72
{
65
73
valueBool = ! EditorPrefs . GetBool ( prefKey ) ;
66
- EditorPrefs . SetBool ( prefKey , valueBool ) ;
67
- Menu . SetChecked ( menuString , valueBool ) ;
68
- EditorApplication . RepaintHierarchyWindow ( ) ;
74
+ EditorPrefs . SetBool ( prefKey , valueBool ) ;
75
+ Menu . SetChecked ( menuString , valueBool ) ;
76
+ EditorApplication . RepaintHierarchyWindow ( ) ;
69
77
}
70
- #endregion
78
+
79
+ [ MenuItem ( MENU_GUTTER_0 , false , 40 ) ]
80
+ private static void SetGutter0 ( ) { SetGutterLevel ( 0 ) ; }
81
+ [ MenuItem ( MENU_GUTTER_1 , false , 41 ) ]
82
+ private static void SetGutter1 ( ) { SetGutterLevel ( 1 ) ; }
83
+ [ MenuItem ( MENU_GUTTER_2 , false , 42 ) ]
84
+ private static void SetGutter2 ( ) { SetGutterLevel ( 2 ) ; }
85
+
86
+ private static void SetGutterLevel ( int gutterLevel )
87
+ {
88
+ gutterLevel = Mathf . Clamp ( gutterLevel , 0 , 2 ) ;
89
+ EditorPrefs . SetInt ( PrefKeyGutterLevel , gutterLevel ) ;
90
+ gutterCount = gutterLevel ;
91
+ UpdateGutterMenu ( gutterCount ) ;
92
+ EditorApplication . RepaintHierarchyWindow ( ) ;
93
+ }
94
+
95
+ private static void UpdateGutterMenu ( int gutterLevel )
96
+ {
97
+ string [ ] gutterKeys = new [ ] { MENU_GUTTER_0 , MENU_GUTTER_1 , MENU_GUTTER_2 } ;
98
+ bool [ ] gutterValues = null ;
99
+ switch ( gutterLevel )
100
+ {
101
+ case 1 :
102
+ gutterValues = new [ ] { false , true , false } ;
103
+ break ;
104
+ case 2 :
105
+ gutterValues = new [ ] { false , false , true } ;
106
+ break ;
107
+ default :
108
+ gutterValues = new [ ] { true , false , false } ;
109
+ break ;
110
+ }
111
+ for ( int i = 0 ; i < gutterKeys . Length ; i ++ )
112
+ {
113
+ string key = gutterKeys [ i ] ;
114
+ bool isChecked = gutterValues [ i ] ;
115
+ Menu . SetChecked ( key , isChecked ) ;
116
+ }
117
+ }
118
+ #endregion
71
119
72
120
static QuickToggle ( )
73
121
{
@@ -134,6 +182,8 @@ public PropagateState(bool isVisibility, bool propagateValue)
134
182
private static bool isFrameFresh ;
135
183
private static bool isMousePressed ;
136
184
185
+ private static int gutterCount = 0 ;
186
+
137
187
private static void ResetVars ( )
138
188
{
139
189
isFrameFresh = false ;
@@ -167,14 +217,20 @@ private static void DrawHierarchyItem(int instanceId, Rect selectionRect)
167
217
return ;
168
218
169
219
// Reserve the draw rects
220
+ float gutterX = selectionRect . height * gutterCount ;
221
+ if ( gutterX > 0 )
222
+ gutterX += selectionRect . height * 0.1f ;
223
+ float xMax = selectionRect . xMax - gutterX ;
224
+
170
225
Rect visRect = new Rect ( selectionRect )
171
226
{
172
- xMin = selectionRect . xMax - ( selectionRect . height * 2.1f ) ,
173
- xMax = selectionRect . xMax - selectionRect . height
227
+ xMin = xMax - ( selectionRect . height * 2.1f ) ,
228
+ xMax = xMax - selectionRect . height
174
229
} ;
175
230
Rect lockRect = new Rect ( selectionRect )
176
231
{
177
- xMin = selectionRect . xMax - selectionRect . height
232
+ xMin = xMax - ( selectionRect . height * 1.05f ) ,
233
+ xMax = xMax - ( selectionRect . height * 0.05f )
178
234
} ;
179
235
180
236
// Get states
0 commit comments