@@ -35,12 +35,13 @@ public Styles()
35
35
}
36
36
}
37
37
38
- const float kScrollBarWidth = 14 ;
39
- const float kFrameWidth = 1f ;
40
- const float kToggleSize = 17 ;
41
- const float kSeparatorHeight = 6 ;
42
- const string kLayerVisible = "Show/Hide Layer" ;
43
- const string kLayerPickable = "Toggle Pickable status this Layer. Non-Pickable items cannot be selected in the Scene View." ;
38
+ const float k_ScrollBarWidth = 14 ;
39
+ const float k_FrameWidth = 1f ;
40
+ const float k_ToggleSize = 17 ;
41
+ const float k_SeparatorHeight = 6 ;
42
+ const float k_JustClosedPeriod = 200 ;
43
+ const string k_LayerVisible = "Show/Hide Layer" ;
44
+ const string k_LayerPickable = "Toggle Pickable status this Layer. Non-Pickable items cannot be selected in the Scene View." ;
44
45
45
46
private static LayerVisibilityWindow s_LayerVisibilityWindow ;
46
47
private static long s_LastClosedTime ;
@@ -86,7 +87,7 @@ internal static bool ShowAtPosition(Rect buttonRect)
86
87
{
87
88
// We could not use realtimeSinceStartUp since it is set to 0 when entering/exitting playmode, we assume an increasing time when comparing time.
88
89
long nowMilliSeconds = System . DateTime . Now . Ticks / System . TimeSpan . TicksPerMillisecond ;
89
- bool justClosed = nowMilliSeconds < s_LastClosedTime + 50 ;
90
+ bool justClosed = nowMilliSeconds < s_LastClosedTime + k_JustClosedPeriod ;
90
91
if ( ! justClosed )
91
92
{
92
93
Event . current . Use ( ) ;
@@ -107,16 +108,16 @@ private void Init(Rect buttonRect)
107
108
108
109
var rowCount = ( s_LayerNames . Count + 2 + 1 + 1 ) ;
109
110
110
- var windowHeight = rowCount * EditorGUI . kSingleLineHeight + kSeparatorHeight ;
111
+ var windowHeight = rowCount * EditorGUI . kSingleLineHeight + k_SeparatorHeight ;
111
112
112
113
int sortingLayerCount = InternalEditorUtility . GetSortingLayerCount ( ) ;
113
114
if ( sortingLayerCount > 1 )
114
115
{
115
- windowHeight += kSeparatorHeight + EditorGUI . kSingleLineHeight ;
116
+ windowHeight += k_SeparatorHeight + EditorGUI . kSingleLineHeight ;
116
117
windowHeight += sortingLayerCount * EditorGUI . kSingleLineHeight ;
117
118
}
118
119
m_ContentHeight = windowHeight ;
119
- windowHeight += 2 * kFrameWidth ;
120
+ windowHeight += 2 * k_FrameWidth ;
120
121
windowHeight = Mathf . Min ( windowHeight , 600 ) ;
121
122
122
123
var windowSize = new Vector2 ( 180 , windowHeight ) ;
@@ -132,12 +133,12 @@ internal void OnGUI()
132
133
if ( s_Styles == null )
133
134
s_Styles = new Styles ( ) ;
134
135
135
- var scrollViewRect = new Rect ( kFrameWidth , kFrameWidth , position . width - 2 * kFrameWidth , position . height - 2 * kFrameWidth ) ;
136
+ var scrollViewRect = new Rect ( k_FrameWidth , k_FrameWidth , position . width - 2 * k_FrameWidth , position . height - 2 * k_FrameWidth ) ;
136
137
var contentRect = new Rect ( 0 , 0 , 1 , m_ContentHeight ) ;
137
138
bool isScrollbarVisible = m_ContentHeight > scrollViewRect . height ;
138
139
float listElementWidth = scrollViewRect . width ;
139
140
if ( isScrollbarVisible )
140
- listElementWidth -= kScrollBarWidth ;
141
+ listElementWidth -= k_ScrollBarWidth ;
141
142
142
143
m_ScrollPosition = GUI . BeginScrollView ( scrollViewRect , m_ScrollPosition , contentRect , false , false , GUI . skin . horizontalScrollbar , GUI . skin . verticalScrollbar , EditorStyles . scrollViewAlt ) ;
143
144
Draw ( listElementWidth ) ;
@@ -174,9 +175,9 @@ private void DrawHeader(ref Rect rect, string text, ref bool even)
174
175
175
176
private void DrawSeparator ( ref Rect rect , bool even )
176
177
{
177
- DrawListBackground ( new Rect ( rect . x + 1 , rect . y , rect . width - 2 , kSeparatorHeight ) , even ) ;
178
+ DrawListBackground ( new Rect ( rect . x + 1 , rect . y , rect . width - 2 , k_SeparatorHeight ) , even ) ;
178
179
GUI . Label ( new Rect ( rect . x + 5 , rect . y + 3 , rect . width - 10 , 3 ) , GUIContent . none , s_Styles . separator ) ;
179
- rect . y += kSeparatorHeight ;
180
+ rect . y += k_SeparatorHeight ;
180
181
}
181
182
182
183
private void Draw ( float listElementWidth )
@@ -279,16 +280,16 @@ private void DoLayerEntry(Rect rect, string layerName, bool even, bool showVisib
279
280
EditorGUI . BeginChangeCheck ( ) ;
280
281
// text (works as visibility toggle as well)
281
282
Rect textRect = rect ;
282
- textRect . width -= kToggleSize * 2 ;
283
+ textRect . width -= k_ToggleSize * 2 ;
283
284
visible = GUI . Toggle ( textRect , visible , EditorGUIUtility . TempContent ( layerName ) , s_Styles . listTextStyle ) ;
284
285
285
286
// visible checkbox
286
- var toggleRect = new Rect ( rect . width - kToggleSize * 2 , rect . y + ( rect . height - kToggleSize ) * 0.5f , kToggleSize , kToggleSize ) ;
287
+ var toggleRect = new Rect ( rect . width - k_ToggleSize * 2 , rect . y + ( rect . height - k_ToggleSize ) * 0.5f , k_ToggleSize , k_ToggleSize ) ;
287
288
visibleChanged = false ;
288
289
if ( showVisible )
289
290
{
290
291
var iconRect = toggleRect ;
291
- var gc = new GUIContent ( string . Empty , visible ? s_Styles . visibleOn : s_Styles . visibleOff , kLayerVisible ) ;
292
+ var gc = new GUIContent ( string . Empty , visible ? s_Styles . visibleOn : s_Styles . visibleOff , k_LayerVisible ) ;
292
293
GUI . Toggle ( iconRect , visible , gc , GUIStyle . none ) ;
293
294
visibleChanged = EditorGUI . EndChangeCheck ( ) ;
294
295
}
@@ -297,9 +298,9 @@ private void DoLayerEntry(Rect rect, string layerName, bool even, bool showVisib
297
298
lockedChanged = false ;
298
299
if ( showLock )
299
300
{
300
- toggleRect . x += kToggleSize ;
301
+ toggleRect . x += k_ToggleSize ;
301
302
EditorGUI . BeginChangeCheck ( ) ;
302
- var gc = new GUIContent ( string . Empty , picked ? s_Styles . notpickable : s_Styles . pickable , kLayerPickable ) ;
303
+ var gc = new GUIContent ( string . Empty , picked ? s_Styles . notpickable : s_Styles . pickable , k_LayerPickable ) ;
303
304
GUI . Toggle ( toggleRect , picked , gc , GUIStyle . none ) ;
304
305
lockedChanged = EditorGUI . EndChangeCheck ( ) ;
305
306
}
0 commit comments