@@ -118,7 +118,7 @@ internal void InternalNetworkStart()
118
118
119
119
private void WarnUnityReflectionMethodUse ( )
120
120
{
121
- MethodInfo [ ] methods = GetType ( ) . GetMethods ( BindingFlags . Instance | BindingFlags . Public | BindingFlags . NonPublic | BindingFlags . Instance | BindingFlags . FlattenHierarchy ) ;
121
+ MethodInfo [ ] methods = GetType ( ) . GetMethods ( BindingFlags . Instance | BindingFlags . Public | BindingFlags . NonPublic | BindingFlags . Instance ) ;
122
122
for ( int i = 0 ; i < methods . Length ; i ++ )
123
123
{
124
124
if ( methods [ i ] . Name == "OnDestroy" )
@@ -209,13 +209,38 @@ protected NetworkedBehaviour GetBehaviour(ushort id)
209
209
internal readonly List < INetworkedVar > networkedVarFields = new List < INetworkedVar > ( ) ;
210
210
private static readonly Dictionary < Type , FieldInfo [ ] > fieldTypes = new Dictionary < Type , FieldInfo [ ] > ( ) ;
211
211
212
+
212
213
private static FieldInfo [ ] GetFieldInfoForType ( Type type )
213
214
{
214
215
if ( ! fieldTypes . ContainsKey ( type ) )
215
- fieldTypes . Add ( type , type . GetFields ( BindingFlags . Public | BindingFlags . NonPublic | BindingFlags . FlattenHierarchy | BindingFlags . Instance ) . OrderBy ( x => x . Name ) . ToArray ( ) ) ;
216
+ fieldTypes . Add ( type , GetFieldInfoForTypeRecursive ( type ) ) ;
217
+
216
218
return fieldTypes [ type ] ;
217
219
}
218
220
221
+
222
+ private static FieldInfo [ ] GetFieldInfoForTypeRecursive ( Type type , List < FieldInfo > list = null )
223
+ {
224
+ if ( list == null )
225
+ {
226
+ list = new List < FieldInfo > ( ) ;
227
+ list . AddRange ( type . GetFields ( BindingFlags . Public | BindingFlags . NonPublic | BindingFlags . Instance ) . OrderBy ( x => x . Name ) ) ;
228
+ }
229
+ else
230
+ {
231
+ list . AddRange ( type . GetFields ( BindingFlags . NonPublic | BindingFlags . Instance ) . OrderBy ( x => x . Name ) ) ;
232
+ }
233
+
234
+ if ( type . BaseType != null && type . BaseType != typeof ( NetworkedBehaviour ) )
235
+ {
236
+ return GetFieldInfoForTypeRecursive ( type . BaseType , list ) ;
237
+ }
238
+ else
239
+ {
240
+ return list . ToArray ( ) ;
241
+ }
242
+ }
243
+
219
244
internal List < INetworkedVar > GetDummyNetworkedVars ( )
220
245
{
221
246
List < INetworkedVar > networkedVars = new List < INetworkedVar > ( ) ;
0 commit comments