@@ -21,7 +21,6 @@ public class ScenePage : WindowPage
21
21
// gameobject list
22
22
private Transform m_currentTransform ;
23
23
private List < GameObjectCache > m_objectList = new List < GameObjectCache > ( ) ;
24
- private float m_timeOfLastUpdate = - 1f ;
25
24
26
25
// search bar
27
26
private bool m_searching = false ;
@@ -45,14 +44,6 @@ public void OnSceneChange()
45
44
46
45
public override void Update ( )
47
46
{
48
- if ( Time . time - m_timeOfLastUpdate < 0.2f )
49
- {
50
- return ;
51
- }
52
- m_timeOfLastUpdate = Time . time ;
53
-
54
- var start = Time . realtimeSinceStartup ;
55
-
56
47
if ( ! m_searching )
57
48
{
58
49
m_objectList = new List < GameObjectCache > ( ) ;
@@ -101,33 +92,39 @@ public override void DrawWindow()
101
92
GUILayout . BeginHorizontal ( null ) ;
102
93
// Current Scene label
103
94
GUILayout . Label ( "Current Scene:" , new GUILayoutOption [ ] { GUILayout . Width ( 120 ) } ) ;
104
- if ( SceneManager . sceneCount > 1 )
95
+ try
105
96
{
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 )
116
101
{
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 ) } ) )
121
108
{
122
- index = 0 ;
109
+ changeWanted = 1 ;
123
110
}
124
- else if ( index > 0 )
111
+ if ( changeWanted != 0 )
125
112
{
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 ;
127
124
}
128
- m_currentScene = scenes [ index ] . name ;
129
125
}
130
126
}
127
+ catch { }
131
128
GUILayout . Label ( "<color=cyan>" + m_currentScene + "</color>" , null ) ; //new GUILayoutOption[] { GUILayout.Width(250) });
132
129
133
130
GUILayout . EndHorizontal ( ) ;
@@ -169,17 +166,11 @@ public override void DrawWindow()
169
166
170
167
if ( m_objectList . Count > 0 )
171
168
{
172
- var start = Time . realtimeSinceStartup ;
173
169
foreach ( var obj in m_objectList )
174
170
{
175
171
//UIStyles.GameobjButton(obj, SetTransformTarget, true, MainMenu.MainRect.width - 170);
176
172
UIStyles . FastGameobjButton ( obj . RefGameObject , obj . EnabledColor , obj . Label , obj . RefGameObject . activeSelf , SetTransformTarget , true , MainMenu . MainRect . width - 170 ) ;
177
173
}
178
- var diff = Time . realtimeSinceStartup - start ;
179
- }
180
- else
181
- {
182
- // if m_currentTransform != null ...
183
174
}
184
175
}
185
176
else // ------ Scene Search results ------
0 commit comments