Skip to content

Commit 7f802dd

Browse files
authored
Added traversal of base types for function finding
Made the function finding traverse base types for components in addition to the component type. This gives access to stuff like LateUpdate on inherited classes where it previously may not have been shown. If you were missing some functions before when using EEE instead of the Unity event editor, this is probably why.
1 parent 87af47e commit 7f802dd

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

EasyEventEditor.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -767,8 +767,7 @@ string GetFunctionDisplayName(SerializedProperty objectProperty, SerializedPrope
767767
break;
768768
}
769769
}
770-
771-
//if (componentID > 1)
770+
772771
objectTypeName += string.Format("({0})", componentID);
773772
}
774773
}
@@ -820,15 +819,25 @@ void FindValidMethods(Object targetObject, PersistentListenerMode listenerMode,
820819
else
821820
argTypes = GetTypeForListenerMode(listenerMode);
822821

823-
MethodInfo[] foundMethods = objectType.GetMethods(BindingFlags.Public | (cachedSettings.showPrivateMembers ? BindingFlags.NonPublic : BindingFlags.Default) | BindingFlags.Instance);
822+
List<MethodInfo> foundMethods = new List<MethodInfo>();
823+
824+
// For some reason BindingFlags.FlattenHierarchy does not seem to work, so we manually traverse the base types instead
825+
while (objectType != null)
826+
{
827+
MethodInfo[] foundMethodsOnType = objectType.GetMethods(BindingFlags.Public | (cachedSettings.showPrivateMembers ? BindingFlags.NonPublic : BindingFlags.Default) | BindingFlags.Instance);
828+
829+
foundMethods.AddRange(foundMethodsOnType);
830+
831+
objectType = objectType.BaseType;
832+
}
824833

825834
foreach (MethodInfo methodInfo in foundMethods)
826835
{
827836
// Sadly we can only use functions with void return type since C# throws an error
828837
if (methodInfo.ReturnType != typeof(void))
829838
continue;
830839

831-
ParameterInfo[] methodParams = methodInfo.GetParameters()/*.Where(method => !method.ParameterType.IsSpecialName).ToArray()*/;
840+
ParameterInfo[] methodParams = methodInfo.GetParameters();
832841
if (methodParams.Length != argTypes.Length)
833842
continue;
834843

0 commit comments

Comments
 (0)