3
3
using UnityEngine ;
4
4
using Explorer . UI . Shared ;
5
5
using Explorer . UI . Main ;
6
+ using Explorer . Unstrip . LayerMasks ;
6
7
#if CPP
7
8
using UnhollowerRuntimeLib ;
8
9
#endif
@@ -17,6 +18,8 @@ public class GameObjectInspector : WindowBase
17
18
18
19
public GameObject TargetGO ;
19
20
21
+ public bool pendingDestroy ;
22
+
20
23
private static bool m_hideControls ;
21
24
22
25
// gui element holders
@@ -43,6 +46,8 @@ public class GameObjectInspector : WindowBase
43
46
private bool m_autoUpdateTransform ;
44
47
private bool m_localContext ;
45
48
49
+ private int m_layer ;
50
+
46
51
private readonly List < Component > m_cachedDestroyList = new List < Component > ( ) ;
47
52
private string m_addComponentInput = "" ;
48
53
@@ -104,16 +109,16 @@ public override void Update()
104
109
{
105
110
try
106
111
{
112
+ if ( pendingDestroy ) return ;
113
+
107
114
if ( Target == null )
108
115
{
109
- ExplorerCore . Log ( "Target is null!" ) ;
110
- DestroyWindow ( ) ;
116
+ DestroyOnException ( new Exception ( "Target was destroyed." ) ) ;
111
117
return ;
112
118
}
113
119
if ( ! TargetGO && ! GetObjectAsGameObject ( ) )
114
120
{
115
- ExplorerCore . Log ( "Target was destroyed!" ) ;
116
- DestroyWindow ( ) ;
121
+ DestroyOnException ( new Exception ( "Target was destroyed." ) ) ;
117
122
return ;
118
123
}
119
124
@@ -132,6 +137,8 @@ public override void Update()
132
137
TargetGO . transform . localScale = m_frozenScale ;
133
138
}
134
139
140
+ m_layer = TargetGO . layer ;
141
+
135
142
// update child objects
136
143
var childList = new List < Transform > ( ) ;
137
144
for ( int i = 0 ; i < TargetGO . transform . childCount ; i ++ )
@@ -163,6 +170,7 @@ public override void Update()
163
170
private void DestroyOnException ( Exception e )
164
171
{
165
172
ExplorerCore . Log ( $ "Exception drawing GameObject Window: { e . GetType ( ) } , { e . Message } ") ;
173
+ pendingDestroy = true ;
166
174
DestroyWindow ( ) ;
167
175
}
168
176
@@ -204,6 +212,8 @@ private void ReflectObject(object obj)
204
212
205
213
public override void WindowFunction ( int windowID )
206
214
{
215
+ if ( pendingDestroy ) return ;
216
+
207
217
try
208
218
{
209
219
var rect = WindowManager . TabView ? TabViewWindow . Instance . m_rect : this . m_rect ;
@@ -250,6 +260,8 @@ public override void WindowFunction(int windowID)
250
260
GUIUnstrip . TextArea ( m_name , new GUILayoutOption [ 0 ] ) ;
251
261
GUILayout . EndHorizontal ( ) ;
252
262
263
+ LayerControls ( ) ;
264
+
253
265
// --- Horizontal Columns section ---
254
266
GUIUnstrip . BeginHorizontal ( new GUILayoutOption [ 0 ] ) ;
255
267
@@ -280,6 +292,34 @@ public override void WindowFunction(int windowID)
280
292
}
281
293
}
282
294
295
+ private void LayerControls ( )
296
+ {
297
+ GUIUnstrip . BeginHorizontal ( ) ;
298
+ GUILayout . Label ( "Layer:" , new GUILayoutOption [ ] { GUILayout . Width ( 50 ) } ) ;
299
+
300
+ if ( GUILayout . Button ( "<" , new GUILayoutOption [ ] { GUILayout . Width ( 30 ) } ) )
301
+ {
302
+ if ( m_layer > 0 )
303
+ {
304
+ m_layer -- ;
305
+ if ( TargetGO ) TargetGO . layer = m_layer ;
306
+ }
307
+ }
308
+ if ( GUILayout . Button ( ">" , new GUILayoutOption [ ] { GUILayout . Width ( 30 ) } ) )
309
+ {
310
+ if ( m_layer < 32 )
311
+ {
312
+ m_layer ++ ;
313
+ if ( TargetGO ) TargetGO . layer = m_layer ;
314
+ }
315
+ }
316
+
317
+ GUILayout . Label ( $ "{ m_layer } (<color=cyan>{ LayerMaskUnstrip . LayerToName ( m_layer ) } </color>)",
318
+ new GUILayoutOption [ ] { GUILayout . Width ( 200 ) } ) ;
319
+
320
+ GUILayout . EndHorizontal ( ) ;
321
+ }
322
+
283
323
private void TransformList ( Rect m_rect )
284
324
{
285
325
GUIUnstrip . BeginVertical ( GUIContent . none , GUI . skin . box , null ) ;
0 commit comments