@@ -20,28 +20,36 @@ public class GUIUnstrip
20
20
public static bool ScrollFailed = false ;
21
21
public static bool ManualUnstripFailed = false ;
22
22
23
- private static GenericStack ScrollStack
23
+ private static GenericStack ScrollStack => m_scrollStack ?? GetScrollStack ( ) ;
24
+ private static PropertyInfo m_scrollViewStatesInfo ;
25
+ private static GenericStack m_scrollStack ;
26
+
27
+ private static GenericStack GetScrollStack ( )
24
28
{
25
- get
29
+ if ( m_scrollViewStatesInfo == null )
26
30
{
27
- if ( m_scrollViewStatesInfo == null )
31
+ if ( typeof ( GUI ) . GetProperty ( "scrollViewStates" , ReflectionHelpers . CommonFlags ) is PropertyInfo scrollStatesInfo )
28
32
{
29
- try
30
- {
31
- m_scrollViewStatesInfo = typeof ( GUI ) . GetProperty ( "scrollViewStates" ) ;
32
- if ( m_scrollViewStatesInfo == null ) throw new Exception ( ) ;
33
- }
34
- catch
35
- {
36
- m_scrollViewStatesInfo = typeof ( GUI ) . GetProperty ( "s_scrollViewStates" ) ;
37
- }
33
+ m_scrollViewStatesInfo = scrollStatesInfo ;
34
+ }
35
+ else if ( typeof ( GUI ) . GetProperty ( "s_ScrollViewStates" , ReflectionHelpers . CommonFlags ) is PropertyInfo s_scrollStatesInfo )
36
+ {
37
+ m_scrollViewStatesInfo = s_scrollStatesInfo ;
38
38
}
39
+ }
39
40
40
- return ( GenericStack ) m_scrollViewStatesInfo ? . GetValue ( null , null ) ;
41
+ if ( m_scrollViewStatesInfo ? . GetValue ( null , null ) is GenericStack stack )
42
+ {
43
+ m_scrollStack = stack ;
44
+ }
45
+ else
46
+ {
47
+ m_scrollStack = new GenericStack ( ) ;
41
48
}
49
+
50
+ return m_scrollStack ;
42
51
}
43
- private static PropertyInfo m_scrollViewStatesInfo ;
44
-
52
+
45
53
public static void Space ( float pixels )
46
54
{
47
55
GUIUtility . CheckOnGUI ( ) ;
@@ -145,7 +153,7 @@ private static Vector2 BeginScrollView_ImplLayout(Vector2 scrollPosition, bool a
145
153
private static Vector2 BeginScrollView_Impl ( Rect position , Vector2 scrollPosition , Rect viewRect , bool alwaysShowHorizontal ,
146
154
bool alwaysShowVertical , GUIStyle horizontalScrollbar , GUIStyle verticalScrollbar , GUIStyle background )
147
155
{
148
- GUIUtility . CheckOnGUI ( ) ;
156
+ // GUIUtility.CheckOnGUI();
149
157
150
158
int controlID = GUIUtility . GetControlID ( GUI . s_ScrollviewHash , FocusType . Passive ) ;
151
159
0 commit comments