@@ -21,7 +21,6 @@ public class ScenePage : WindowPage
2121 // gameobject list
2222 private Transform m_currentTransform ;
2323 private List < GameObjectCache > m_objectList = new List < GameObjectCache > ( ) ;
24- private float m_timeOfLastUpdate = - 1f ;
2524
2625 // search bar
2726 private bool m_searching = false ;
@@ -45,14 +44,6 @@ public void OnSceneChange()
4544
4645 public override void Update ( )
4746 {
48- if ( Time . time - m_timeOfLastUpdate < 0.2f )
49- {
50- return ;
51- }
52- m_timeOfLastUpdate = Time . time ;
53-
54- var start = Time . realtimeSinceStartup ;
55-
5647 if ( ! m_searching )
5748 {
5849 m_objectList = new List < GameObjectCache > ( ) ;
@@ -101,33 +92,39 @@ public override void DrawWindow()
10192 GUILayout . BeginHorizontal ( null ) ;
10293 // Current Scene label
10394 GUILayout . Label ( "Current Scene:" , new GUILayoutOption [ ] { GUILayout . Width ( 120 ) } ) ;
104- if ( SceneManager . sceneCount > 1 )
95+ try
10596 {
106- int changeWanted = 0 ;
107- if ( GUILayout . Button ( "<" , new GUILayoutOption [ ] { GUILayout . Width ( 30 ) } ) )
108- {
109- changeWanted = - 1 ;
110- }
111- if ( GUILayout . Button ( ">" , new GUILayoutOption [ ] { GUILayout . Width ( 30 ) } ) )
112- {
113- changeWanted = 1 ;
114- }
115- if ( changeWanted != 0 )
97+ // Need to do 'ToList()' so the object isn't cleaned up by Il2Cpp GC.
98+ var scenes = SceneManager . GetAllScenes ( ) . ToList ( ) ;
99+
100+ if ( scenes . Count > 1 )
116101 {
117- var scenes = SceneManager . GetAllScenes ( ) ;
118- int index = scenes . IndexOf ( SceneManager . GetSceneByName ( m_currentScene ) ) ;
119- index += changeWanted ;
120- if ( index >= scenes . Count - 1 )
102+ int changeWanted = 0 ;
103+ if ( GUILayout . Button ( "<" , new GUILayoutOption [ ] { GUILayout . Width ( 30 ) } ) )
104+ {
105+ changeWanted = - 1 ;
106+ }
107+ if ( GUILayout . Button ( ">" , new GUILayoutOption [ ] { GUILayout . Width ( 30 ) } ) )
121108 {
122- index = 0 ;
109+ changeWanted = 1 ;
123110 }
124- else if ( index > 0 )
111+ if ( changeWanted != 0 )
125112 {
126- index = scenes . Count - 1 ;
113+ int index = scenes . IndexOf ( SceneManager . GetSceneByName ( m_currentScene ) ) ;
114+ index += changeWanted ;
115+ if ( index > scenes . Count - 1 )
116+ {
117+ index = 0 ;
118+ }
119+ else if ( index < 0 )
120+ {
121+ index = scenes . Count - 1 ;
122+ }
123+ m_currentScene = scenes [ index ] . name ;
127124 }
128- m_currentScene = scenes [ index ] . name ;
129125 }
130126 }
127+ catch { }
131128 GUILayout . Label ( "<color=cyan>" + m_currentScene + "</color>" , null ) ; //new GUILayoutOption[] { GUILayout.Width(250) });
132129
133130 GUILayout . EndHorizontal ( ) ;
@@ -169,17 +166,11 @@ public override void DrawWindow()
169166
170167 if ( m_objectList . Count > 0 )
171168 {
172- var start = Time . realtimeSinceStartup ;
173169 foreach ( var obj in m_objectList )
174170 {
175171 //UIStyles.GameobjButton(obj, SetTransformTarget, true, MainMenu.MainRect.width - 170);
176172 UIStyles . FastGameobjButton ( obj . RefGameObject , obj . EnabledColor , obj . Label , obj . RefGameObject . activeSelf , SetTransformTarget , true , MainMenu . MainRect . width - 170 ) ;
177173 }
178- var diff = Time . realtimeSinceStartup - start ;
179- }
180- else
181- {
182- // if m_currentTransform != null ...
183174 }
184175 }
185176 else // ------ Scene Search results ------
0 commit comments