AmbiguousMatchException on UnityEvent type drawer instatiation

Issue #367 resolved
Alex Slavski created an issue

Windows 10 64x, Unity 2018.2.0f2, Odin Inspector v 1.0.6.9 Monobehaviour with UnityEvent:

using UnityEngine;
using UnityEngine.Events;
using Sirenix.OdinInspector;

public class EventListener : MonoBehaviour
{
    public GameEvent[] Events;
    public UnityEvent Response;

    void OnEnable()
    {
        foreach (GameEvent ev in Events) { ev.Register(this); }
    }
    void OnDisable()
    {
        foreach (GameEvent ev in Events) { ev.DeRegister(this); }
    }

    public void OnEventRaised() { Response.Invoke(); }
}

When it is attached to the object (in Editor and at runtime) it causes a following log:

Encountered the following exception when trying to instantiate a drawer of type UnityEventDrawer<UnityEvent>
UnityEngine.Debug:Log(Object)
Sirenix.OdinInspector.Editor.<>c__DisplayClass35_0:<GetAllDrawers>b__2(DrawerInfo)
System.Linq.<CreateWhereIterator>c__Iterator1D`1:MoveNext()
Sirenix.Utilities.<Append>d__19`1:MoveNext() (at F:/Sirenix/Sirenix Solution/Sirenix.Utilities/Extensions/LinqExtensions.cs:343)
System.Linq.Enumerable:ToArray(IEnumerable`1)
Sirenix.OdinInspector.Editor.DrawerLocator:GetAllDrawers(Type, Type, List`1, Boolean)
Sirenix.OdinInspector.Editor.DrawerLocator:GetValueDrawers(Type) (at F:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/Infos/InspectorPropertyInfo.cs:710)
Sirenix.OdinInspector.Editor.DrawerLocator:GetDrawersForMemberInfo(MemberInfo, Type, Boolean) (at F:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/Infos/InspectorPropertyInfo.cs:524)
Sirenix.OdinInspector.Editor.DrawerLocator:GetDrawersForProperty(InspectorProperty) (at F:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/Infos/InspectorPropertyInfo.cs:535)
Sirenix.OdinInspector.Editor.InspectorUtilities:DrawProperty(InspectorProperty, GUIContent)
Sirenix.OdinInspector.Editor.InspectorUtilities:DrawProperty(InspectorProperty)
Sirenix.OdinInspector.Editor.InspectorUtilities:DrawPropertiesInTree(PropertyTree)
Sirenix.OdinInspector.Editor.PropertyTree:Draw(Boolean)
Sirenix.OdinInspector.Editor.OdinEditor:DrawTree() (at F:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/Children/PropertyValueCollection.cs:541)
Sirenix.OdinInspector.Editor.OdinEditor:DrawOdinInspector() (at F:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/Children/PropertyValueCollection.cs:533)
Sirenix.OdinInspector.Editor.OdinEditor:OnInspectorGUI() (at F:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/Children/PropertyValueCollection.cs:516)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

And then a following error:

AmbiguousMatchException: Ambiguous matching in method resolution
System.Reflection.Binder.FindMostDerivedMatch (System.Reflection.MethodBase[] match) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/Binder.cs:106)
System.MonoType.GetMethodImpl (System.String name, BindingFlags bindingAttr, System.Reflection.Binder binder, CallingConventions callConvention, System.Type[] types, System.Reflection.ParameterModifier[] modifiers) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/MonoType.cs:245)
System.Type.GetMethod (System.String name, BindingFlags bindingAttr) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/Type.cs:787)
Sirenix.OdinInspector.Editor.UnityPropertyHandlerUtility..cctor () (at F:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/Context/PropertyContext.cs:60)
Rethrow as TypeInitializationException: An exception was thrown by the type initializer for Sirenix.OdinInspector.Editor.UnityPropertyHandlerUtility
Sirenix.OdinInspector.Editor.UnityPropertyDrawer`2[UnityEditorInternal.UnityEventDrawer,UnityEngine.Events.UnityEvent]..ctor ()
Sirenix.OdinInspector.Editor.Drawers.UnityEventDrawer`1[UnityEngine.Events.UnityEvent]..ctor () (at F:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Value Drawers/Vector4Drawer.cs:66)
System.Reflection.MonoCMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:513)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoCMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:519)
System.Reflection.MonoCMethod.Invoke (BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:528)
System.Reflection.ConstructorInfo.Invoke (System.Object[] parameters) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/ConstructorInfo.cs:77)
System.Activator.CreateInstance (System.Type type, Boolean nonPublic) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/Activator.cs:372)
System.Activator.CreateInstance (System.Type type) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/Activator.cs:254)
Sirenix.OdinInspector.Editor.DrawerLocator.GetDrawer (System.Type drawerType, Boolean forceUniqueDrawerInstance)
Sirenix.OdinInspector.Editor.DrawerLocator+<>c__DisplayClass35_0.<GetAllDrawers>b__2 (Sirenix.OdinInspector.Editor.DrawerInfo info)
UnityEngine.Debug:LogException(Exception)
Sirenix.OdinInspector.Editor.<>c__DisplayClass35_0:<GetAllDrawers>b__2(DrawerInfo)
System.Linq.<CreateWhereIterator>c__Iterator1D`1:MoveNext()
Sirenix.Utilities.<Append>d__19`1:MoveNext() (at F:/Sirenix/Sirenix Solution/Sirenix.Utilities/Extensions/LinqExtensions.cs:343)
System.Linq.Enumerable:ToArray(IEnumerable`1)
Sirenix.OdinInspector.Editor.DrawerLocator:GetAllDrawers(Type, Type, List`1, Boolean)
Sirenix.OdinInspector.Editor.DrawerLocator:GetValueDrawers(Type) (at F:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/Infos/InspectorPropertyInfo.cs:710)
Sirenix.OdinInspector.Editor.DrawerLocator:GetDrawersForMemberInfo(MemberInfo, Type, Boolean) (at F:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/Infos/InspectorPropertyInfo.cs:524)
Sirenix.OdinInspector.Editor.DrawerLocator:GetDrawersForProperty(InspectorProperty) (at F:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/Infos/InspectorPropertyInfo.cs:535)
Sirenix.OdinInspector.Editor.InspectorUtilities:DrawProperty(InspectorProperty, GUIContent)
Sirenix.OdinInspector.Editor.InspectorUtilities:DrawProperty(InspectorProperty)
Sirenix.OdinInspector.Editor.InspectorUtilities:DrawPropertiesInTree(PropertyTree)
Sirenix.OdinInspector.Editor.PropertyTree:Draw(Boolean)
Sirenix.OdinInspector.Editor.OdinEditor:DrawTree() (at F:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/Children/PropertyValueCollection.cs:541)
Sirenix.OdinInspector.Editor.OdinEditor:DrawOdinInspector() (at F:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/Children/PropertyValueCollection.cs:533)
Sirenix.OdinInspector.Editor.OdinEditor:OnInspectorGUI() (at F:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/Children/PropertyValueCollection.cs:516)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

Comments (7)

  1. Rubén Blanco

    Same error here (also same version of Unity and Odin as the OP).

    To me this happens with I2 and Odin. A script from I2 tries to draw a property which has a CustomPropertyDrawer (LocalizedString property in case you want to test with this plugin) and this error pops up.

    Disabling Odin in the script which uses that property or using DrawWithUnity makes this error to not appear.

  2. Tor Esa Vestergaard

    It's a bit uncertain, right now. We're working a few final bugs, and we have a lot of documentation and tutorials to write.

  3. Tor Esa Vestergaard

    Weeks, maybe as much as a month or two, but certainly no more than that. Apart from those bugs (which we are making good progress on, it seems) the beta is there on a technical level and is generally a lot more stable and bug-free than the current 1.0.6.9 release. Soon, it will just be a matter of documentation, compiling an utterly massive set of release notes, and writing a bunch of tutorials for all the new features.

  4. Log in to comment