Error when pressing [Button] in overriden method

Issue #15 resolved
João Cabral created an issue

I get the following in the console:

The following exception was thrown when drawing property ActivateMachine with the following chain of property value drawers: 
MethodPropertyDrawer<FurnaceSpawner>.
UnityEngine.Debug:Log(Object)
Sirenix.OdinInspector.Editor.InspectorUtilities:DrawProperty(InspectorProperty, GUIContent, GUILayoutOption[]) (at C:/Users/Bjarke/Desktop/Projects/sirenix-development-framework/Sirenix Solution/Sirenix.OdinInspector.Editor/Misc/InspectorUtilities.cs:387)
Sirenix.OdinInspector.Editor.InspectorUtilities:DrawProperty(InspectorProperty) (at C:/Users/Bjarke/Desktop/Projects/sirenix-development-framework/Sirenix Solution/Sirenix.OdinInspector.Editor/Misc/InspectorUtilities.cs:295)
Sirenix.OdinInspector.Editor.InspectorUtilities:DrawPropertyTree(PropertyTree, Boolean, Func`2) (at C:/Users/Bjarke/Desktop/Projects/sirenix-development-framework/Sirenix Solution/Sirenix.OdinInspector.Editor/Misc/InspectorUtilities.cs:203)
Sirenix.OdinInspector.Editor.PropertyTree:Draw(Boolean) (at C:/Users/Bjarke/Desktop/Projects/sirenix-development-framework/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/PropertyTree.cs:88)
Sirenix.OdinInspector.Editor.OdinEditor:OnInspectorGUI() (at C:/Users/Bjarke/Desktop/Projects/sirenix-development-framework/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/OdinEditor.cs:168)
UnityEditor.DockArea:OnGUI()
InvalidProgramException: Invalid IL code in (wrapper dynamic-method) object:FurnaceSpawner.call_ActivateMachine (object): IL_000b: ret       
System.Delegate.CreateDelegate (System.Type type, System.Object firstArgument, System.Reflection.MethodInfo method, Boolean throwOnBindFailure) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/Delegate.cs:268)
System.Delegate.CreateDelegate (System.Type type, System.Reflection.MethodInfo method, Boolean throwOnBindFailure) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/Delegate.cs:291)
System.Delegate.CreateDelegate (System.Type type, System.Reflection.MethodInfo method) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/Delegate.cs:295)
System.Reflection.Emit.DynamicMethod.CreateDelegate (System.Type delegateType) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection.Emit/DynamicMethod.cs:179)
Sirenix.Utilities.EmitUtilities.CreateWeakInstanceMethodCaller (System.Reflection.MethodInfo methodInfo) (at C:/Users/Bjarke/Desktop/Projects/sirenix-development-framework/Sirenix Solution/Sirenix.Utilities/Misc/EmitUtilities.cs:1230)
Sirenix.OdinInspector.Editor.Drawers.MethodPropertyDrawer`1[FurnaceSpawner].DrawPropertyImplementation (Sirenix.OdinInspector.Editor.InspectorProperty property, UnityEngine.GUIContent label, UnityEngine.GUILayoutOption[] options) (at C:/Users/Bjarke/Desktop/Projects/sirenix-development-framework/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Misc Drawers/MethodPropertyDrawer.cs:70)
Sirenix.OdinInspector.Editor.OdinDrawer.DrawProperty (Sirenix.OdinInspector.Editor.InspectorProperty property, UnityEngine.GUIContent label, UnityEngine.GUILayoutOption[] options) (at C:/Users/Bjarke/Desktop/Projects/sirenix-development-framework/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/OdinDrawer.cs:101)
Sirenix.OdinInspector.Editor.InspectorUtilities.DrawProperty (Sirenix.OdinInspector.Editor.InspectorProperty property, UnityEngine.GUIContent label, UnityEngine.GUILayoutOption[] options) (at C:/Users/Bjarke/Desktop/Projects/sirenix-development-framework/Sirenix Solution/Sirenix.OdinInspector.Editor/Misc/InspectorUtilities.cs:353)
UnityEngine.Debug:LogException(Exception)
Sirenix.OdinInspector.Editor.InspectorUtilities:DrawProperty(InspectorProperty, GUIContent, GUILayoutOption[]) (at C:/Users/Bjarke/Desktop/Projects/sirenix-development-framework/Sirenix Solution/Sirenix.OdinInspector.Editor/Misc/InspectorUtilities.cs:388)
Sirenix.OdinInspector.Editor.InspectorUtilities:DrawProperty(InspectorProperty) (at C:/Users/Bjarke/Desktop/Projects/sirenix-development-framework/Sirenix Solution/Sirenix.OdinInspector.Editor/Misc/InspectorUtilities.cs:295)
Sirenix.OdinInspector.Editor.InspectorUtilities:DrawPropertyTree(PropertyTree, Boolean, Func`2) (at C:/Users/Bjarke/Desktop/Projects/sirenix-development-framework/Sirenix Solution/Sirenix.OdinInspector.Editor/Misc/InspectorUtilities.cs:203)
Sirenix.OdinInspector.Editor.PropertyTree:Draw(Boolean) (at C:/Users/Bjarke/Desktop/Projects/sirenix-development-framework/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/PropertyTree.cs:88)
Sirenix.OdinInspector.Editor.OdinEditor:OnInspectorGUI() (at C:/Users/Bjarke/Desktop/Projects/sirenix-development-framework/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/OdinEditor.cs:168)
UnityEditor.DockArea:OnGUI()

Comments (2)

  1. Tor Esa Vestergaard

    This issue has been replicated, and a fix has been introduced in the next patch. The issue was that if a [Button] or [OnInspectorGUI] method had a non-void return type, we emitted invalid IL to invoke the method - essentially, we forgot to pop the method's returned value off the stack before emitting the return opcode.

    Until you receive the next patch, you can 'fix' the issue by making sure your methods decorated with [Button] all return void.

  2. Log in to comment