@@ -35,12 +35,13 @@ public Styles()
3535 }
3636 }
3737
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." ;
4445
4546 private static LayerVisibilityWindow s_LayerVisibilityWindow ;
4647 private static long s_LastClosedTime ;
@@ -86,7 +87,7 @@ internal static bool ShowAtPosition(Rect buttonRect)
8687 {
8788 // We could not use realtimeSinceStartUp since it is set to 0 when entering/exitting playmode, we assume an increasing time when comparing time.
8889 long nowMilliSeconds = System . DateTime . Now . Ticks / System . TimeSpan . TicksPerMillisecond ;
89- bool justClosed = nowMilliSeconds < s_LastClosedTime + 50 ;
90+ bool justClosed = nowMilliSeconds < s_LastClosedTime + k_JustClosedPeriod ;
9091 if ( ! justClosed )
9192 {
9293 Event . current . Use ( ) ;
@@ -107,16 +108,16 @@ private void Init(Rect buttonRect)
107108
108109 var rowCount = ( s_LayerNames . Count + 2 + 1 + 1 ) ;
109110
110- var windowHeight = rowCount * EditorGUI . kSingleLineHeight + kSeparatorHeight ;
111+ var windowHeight = rowCount * EditorGUI . kSingleLineHeight + k_SeparatorHeight ;
111112
112113 int sortingLayerCount = InternalEditorUtility . GetSortingLayerCount ( ) ;
113114 if ( sortingLayerCount > 1 )
114115 {
115- windowHeight += kSeparatorHeight + EditorGUI . kSingleLineHeight ;
116+ windowHeight += k_SeparatorHeight + EditorGUI . kSingleLineHeight ;
116117 windowHeight += sortingLayerCount * EditorGUI . kSingleLineHeight ;
117118 }
118119 m_ContentHeight = windowHeight ;
119- windowHeight += 2 * kFrameWidth ;
120+ windowHeight += 2 * k_FrameWidth ;
120121 windowHeight = Mathf . Min ( windowHeight , 600 ) ;
121122
122123 var windowSize = new Vector2 ( 180 , windowHeight ) ;
@@ -132,12 +133,12 @@ internal void OnGUI()
132133 if ( s_Styles == null )
133134 s_Styles = new Styles ( ) ;
134135
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 ) ;
136137 var contentRect = new Rect ( 0 , 0 , 1 , m_ContentHeight ) ;
137138 bool isScrollbarVisible = m_ContentHeight > scrollViewRect . height ;
138139 float listElementWidth = scrollViewRect . width ;
139140 if ( isScrollbarVisible )
140- listElementWidth -= kScrollBarWidth ;
141+ listElementWidth -= k_ScrollBarWidth ;
141142
142143 m_ScrollPosition = GUI . BeginScrollView ( scrollViewRect , m_ScrollPosition , contentRect , false , false , GUI . skin . horizontalScrollbar , GUI . skin . verticalScrollbar , EditorStyles . scrollViewAlt ) ;
143144 Draw ( listElementWidth ) ;
@@ -174,9 +175,9 @@ private void DrawHeader(ref Rect rect, string text, ref bool even)
174175
175176 private void DrawSeparator ( ref Rect rect , bool even )
176177 {
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 ) ;
178179 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 ;
180181 }
181182
182183 private void Draw ( float listElementWidth )
@@ -279,16 +280,16 @@ private void DoLayerEntry(Rect rect, string layerName, bool even, bool showVisib
279280 EditorGUI . BeginChangeCheck ( ) ;
280281 // text (works as visibility toggle as well)
281282 Rect textRect = rect ;
282- textRect . width -= kToggleSize * 2 ;
283+ textRect . width -= k_ToggleSize * 2 ;
283284 visible = GUI . Toggle ( textRect , visible , EditorGUIUtility . TempContent ( layerName ) , s_Styles . listTextStyle ) ;
284285
285286 // 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 ) ;
287288 visibleChanged = false ;
288289 if ( showVisible )
289290 {
290291 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 ) ;
292293 GUI . Toggle ( iconRect , visible , gc , GUIStyle . none ) ;
293294 visibleChanged = EditorGUI . EndChangeCheck ( ) ;
294295 }
@@ -297,9 +298,9 @@ private void DoLayerEntry(Rect rect, string layerName, bool even, bool showVisib
297298 lockedChanged = false ;
298299 if ( showLock )
299300 {
300- toggleRect . x += kToggleSize ;
301+ toggleRect . x += k_ToggleSize ;
301302 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 ) ;
303304 GUI . Toggle ( toggleRect , picked , gc , GUIStyle . none ) ;
304305 lockedChanged = EditorGUI . EndChangeCheck ( ) ;
305306 }
0 commit comments