@@ -118,7 +118,7 @@ internal void InternalNetworkStart()
118118
119119 private void WarnUnityReflectionMethodUse ( )
120120 {
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 ) ;
122122 for ( int i = 0 ; i < methods . Length ; i ++ )
123123 {
124124 if ( methods [ i ] . Name == "OnDestroy" )
@@ -209,13 +209,38 @@ protected NetworkedBehaviour GetBehaviour(ushort id)
209209 internal readonly List < INetworkedVar > networkedVarFields = new List < INetworkedVar > ( ) ;
210210 private static readonly Dictionary < Type , FieldInfo [ ] > fieldTypes = new Dictionary < Type , FieldInfo [ ] > ( ) ;
211211
212+
212213 private static FieldInfo [ ] GetFieldInfoForType ( Type type )
213214 {
214215 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+
216218 return fieldTypes [ type ] ;
217219 }
218220
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+
219244 internal List < INetworkedVar > GetDummyNetworkedVars ( )
220245 {
221246 List < INetworkedVar > networkedVars = new List < INetworkedVar > ( ) ;
0 commit comments