diff --git a/Assets/Impossible Odds/Toolkit/Runtime/Core/DelegateExtensions.cs b/Assets/Impossible Odds/Toolkit/Runtime/Core/DelegateExtensions.cs index ada6d37..153d782 100644 --- a/Assets/Impossible Odds/Toolkit/Runtime/Core/DelegateExtensions.cs +++ b/Assets/Impossible Odds/Toolkit/Runtime/Core/DelegateExtensions.cs @@ -277,19 +277,20 @@ private static List GetDelegatesForType(Type type) // Find all delegate fields through the type hierarchy. List delegates = new List(); - while ((type != null) && (type != typeof(object))) + Type typeIt = type; + while ((typeIt != null) && (typeIt != typeof(object))) { - FieldInfo[] fields = type.GetFields(flags); + FieldInfo[] fields = typeIt.GetFields(flags); foreach (FieldInfo field in fields) { - if ((field.DeclaringType == type) && delegateType.IsAssignableFrom(field.FieldType)) + if ((field.DeclaringType == typeIt) && delegateType.IsAssignableFrom(field.FieldType)) { delegates.Add(field); } } - type = type.BaseType; + typeIt = typeIt.BaseType; } return delegateCache.GetOrAdd(type, delegates);