@@ -147,32 +147,39 @@ public void UpdateComponents()
147
147
var behaviours = GOTarget . GetComponents < Behaviour > ( ) ;
148
148
149
149
bool needRefresh = false ;
150
- if ( comps . Length != componentEntries . Count || behaviours . Length != behaviourEntries . Count )
151
- {
152
- needRefresh = true ;
153
- }
154
- else
150
+
151
+ int count = 0 ;
152
+ foreach ( var comp in comps )
155
153
{
156
- foreach ( var comp in comps )
154
+ if ( ! comp )
155
+ continue ;
156
+ count ++ ;
157
+ if ( ! compInstanceIDs . Contains ( comp . GetInstanceID ( ) ) )
157
158
{
158
- if ( ! compInstanceIDs . Contains ( comp . GetInstanceID ( ) ) )
159
- {
160
- needRefresh = true ;
161
- break ;
162
- }
159
+ needRefresh = true ;
160
+ break ;
163
161
}
164
-
165
- if ( ! needRefresh )
162
+ }
163
+ if ( ! needRefresh )
164
+ {
165
+ if ( count != componentEntries . Count )
166
+ needRefresh = true ;
167
+ else
166
168
{
167
- for ( int i = 0 ; i < behaviours . Length ; i ++ )
169
+ count = 0 ;
170
+ foreach ( var behaviour in behaviours )
168
171
{
169
- var behaviour = behaviours [ i ] ;
170
- if ( behaviour . enabled != behaviourEnabledStates [ i ] )
172
+ if ( ! behaviour )
173
+ continue ;
174
+ if ( count >= behaviourEnabledStates . Count || behaviour . enabled != behaviourEnabledStates [ count ] )
171
175
{
172
176
needRefresh = true ;
173
177
break ;
174
178
}
179
+ count ++ ;
175
180
}
181
+ if ( ! needRefresh && count != behaviourEntries . Count )
182
+ needRefresh = true ;
176
183
}
177
184
}
178
185
@@ -181,9 +188,9 @@ public void UpdateComponents()
181
188
182
189
componentEntries . Clear ( ) ;
183
190
compInstanceIDs . Clear ( ) ;
184
-
185
191
foreach ( var comp in comps )
186
192
{
193
+ if ( ! comp ) continue ;
187
194
componentEntries . Add ( comp ) ;
188
195
compInstanceIDs . Add ( comp . GetInstanceID ( ) ) ;
189
196
}
@@ -192,6 +199,7 @@ public void UpdateComponents()
192
199
behaviourEnabledStates . Clear ( ) ;
193
200
foreach ( var behaviour in behaviours )
194
201
{
202
+ if ( ! behaviour ) continue ;
195
203
behaviourEntries . Add ( behaviour ) ;
196
204
behaviourEnabledStates . Add ( behaviour . enabled ) ;
197
205
}
@@ -211,7 +219,7 @@ private void OnAddChildClicked(string input)
211
219
212
220
private void OnAddComponentClicked ( string input )
213
221
{
214
- if ( ReflectionUtility . AllTypes . TryGetValue ( input , out Type type ) )
222
+ if ( ReflectionUtility . GetTypeByName ( input ) is Type type )
215
223
{
216
224
try
217
225
{
0 commit comments