Skip to content

Commit 9d9cd05

Browse files
committed
Add recursive function for getting methods on NetworkedBehavoiur child classes.
1 parent f0b3312 commit 9d9cd05

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

MLAPI/MonoBehaviours/Core/NetworkedBehaviour.cs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,29 @@ private ulong HashMethodName(string name)
413413

414414
return 0;
415415
}
416-
416+
417+
private MethodInfo[] getNetworkedBehaviorChildClassesMethods(Type type, List<MethodInfo> list = null)
418+
{
419+
if (list == null)
420+
{
421+
list = new List<MethodInfo>();
422+
list.AddRange(type.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance));
423+
}
424+
else
425+
{
426+
list.AddRange(type.GetMethods(BindingFlags.NonPublic | BindingFlags.Instance));
427+
}
428+
429+
if (type.BaseType != null && type.BaseType != typeof(NetworkedBehaviour))
430+
{
431+
return getNetworkedBehaviorChildClassesMethods(type.BaseType, list);
432+
}
433+
else
434+
{
435+
return list.ToArray();
436+
}
437+
}
438+
417439
private void CacheAttributes()
418440
{
419441
Type type = GetType();
@@ -425,7 +447,7 @@ private void CacheAttributes()
425447
if (Methods.ContainsKey(type)) methods = Methods[type];
426448
else
427449
{
428-
methods = type.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
450+
methods = getNetworkedBehaviorChildClassesMethods(type);
429451
Methods.Add(type, methods);
430452
}
431453

0 commit comments

Comments
 (0)