MissingMethodException: Cannot create an abstract class 'BehaviorDesigner.Runtime.SharedVariable'.

favoyang

New member
Task: Has Received Event

Steps
- Create a shared float value, say targetValue
- Add "Has Received Event" Task
- Set "Stored Value 1" to targetValue
- Raise exception MissingMethodException

C#:
MissingMethodException: Cannot create an abstract class 'BehaviorDesigner.Runtime.SharedVariable'.
System.RuntimeType.CreateInstanceMono (System.Boolean nonPublic) (at <437ba245d8404784b9fbab9b439ac908>:0)
System.RuntimeType.CreateInstanceSlow (System.Boolean publicOnly, System.Boolean skipCheckThis, System.Boolean fillCache, System.Threading.StackCrawlMark& stackMark) (at <437ba245d8404784b9fbab9b439ac908>:0)
System.RuntimeType.CreateInstanceDefaultCtor (System.Boolean publicOnly, System.Boolean skipCheckThis, System.Boolean fillCache, System.Threading.StackCrawlMark& stackMark) (at <437ba245d8404784b9fbab9b439ac908>:0)
System.Activator.CreateInstance (System.Type type, System.Boolean nonPublic) (at <437ba245d8404784b9fbab9b439ac908>:0)
BehaviorDesigner.Editor.FieldInspector.DrawSharedVariable (BehaviorDesigner.Runtime.Tasks.Task task, UnityEngine.GUIContent guiContent, System.Reflection.FieldInfo fieldInfo, System.Type fieldType, BehaviorDesigner.Runtime.SharedVariable sharedVariable) (at <d917a79751444cb5b4a389f044c18334>:0)
BehaviorDesigner.Editor.TaskInspector.DrawSharedVariableValue (BehaviorDesigner.Runtime.BehaviorSource behaviorSource, System.Reflection.FieldInfo field, UnityEngine.GUIContent guiContent, BehaviorDesigner.Runtime.Tasks.Task task, BehaviorDesigner.Runtime.SharedVariable sharedVariable, System.Boolean isReflectionTask, System.Boolean enabled, System.Boolean drawWatch) (at <d917a79751444cb5b4a389f044c18334>:0)
BehaviorDesigner.Editor.TaskInspector.DrawObjectFields (BehaviorDesigner.Runtime.BehaviorSource behaviorSource, BehaviorDesigner.Editor.TaskList taskList, BehaviorDesigner.Runtime.Tasks.Task task, System.Object obj, System.Boolean enabled, System.Boolean drawWatch) (at <d917a79751444cb5b4a389f044c18334>:0)
BehaviorDesigner.Editor.TaskInspector.DrawTaskFields (BehaviorDesigner.Runtime.BehaviorSource behaviorSource, BehaviorDesigner.Editor.TaskList taskList, BehaviorDesigner.Runtime.Tasks.Task task, System.Boolean enabled) (at <d917a79751444cb5b4a389f044c18334>:0)
BehaviorDesigner.Editor.TaskInspector.DrawTaskInspector (BehaviorDesigner.Runtime.BehaviorSource behaviorSource, BehaviorDesigner.Editor.TaskList taskList, BehaviorDesigner.Runtime.Tasks.Task task, System.Boolean enabled) (at <d917a79751444cb5b4a389f044c18334>:0)
BehaviorDesigner.Editor.BehaviorDesignerWindow.DrawPropertiesBox () (at <d917a79751444cb5b4a389f044c18334>:0)
BehaviorDesigner.Editor.BehaviorDesignerWindow.Draw () (at <d917a79751444cb5b4a389f044c18334>:0)
BehaviorDesigner.Editor.BehaviorDesignerWindow.OnGUI () (at <d917a79751444cb5b4a389f044c18334>:0)
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <437ba245d8404784b9fbab9b439ac908>:0)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <437ba245d8404784b9fbab9b439ac908>:0)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <437ba245d8404784b9fbab9b439ac908>:0)
UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) (at <887a438259064e89922419bc7b8810ab>:0)
UnityEditor.HostView.Invoke (System.String methodName) (at <887a438259064e89922419bc7b8810ab>:0)
UnityEditor.HostView.InvokeOnGUI (UnityEngine.Rect onGUIPosition, UnityEngine.Rect viewRect) (at <887a438259064e89922419bc7b8810ab>:0)
UnityEditor.DockArea.DrawView (UnityEngine.Rect viewRect, UnityEngine.Rect dockAreaRect) (at <887a438259064e89922419bc7b8810ab>:0)
UnityEditor.DockArea.OldOnGUI () (at <887a438259064e89922419bc7b8810ab>:0)
UnityEngine.UIElements.IMGUIContainer.DoOnGUI (UnityEngine.Event evt, UnityEngine.Matrix4x4 parentTransform, UnityEngine.Rect clippingRect, System.Boolean isComputingLayout, UnityEngine.Rect layoutSize, System.Boolean canAffectFocus) (at <085559680b9141e8b8c144c684aaa6d7>:0)
UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, UnityEngine.Matrix4x4 worldTransform, UnityEngine.Rect clippingRect, System.Boolean canAffectFocus) (at <085559680b9141e8b8c144c684aaa6d7>:0)
UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, System.Boolean canAffectFocus) (at <085559680b9141e8b8c144c684aaa6d7>:0)
UnityEngine.UIElements.IMGUIContainer.SendEventToIMGUI (UnityEngine.UIElements.EventBase evt, System.Boolean canAffectFocus) (at <085559680b9141e8b8c144c684aaa6d7>:0)
UnityEngine.UIElements.CommandEventDispatchingStrategy.DispatchEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at <085559680b9141e8b8c144c684aaa6d7>:0)
UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at <085559680b9141e8b8c144c684aaa6d7>:0)
UnityEngine.UIElements.EventDispatcher.Dispatch (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel, UnityEngine.UIElements.DispatchMode dispatchMode) (at <085559680b9141e8b8c144c684aaa6d7>:0)
UnityEngine.UIElements.BaseVisualElementPanel.SendEvent (UnityEngine.UIElements.EventBase e, UnityEngine.UIElements.DispatchMode dispatchMode) (at <085559680b9141e8b8c144c684aaa6d7>:0)
UnityEngine.UIElements.UIElementsUtility.DoDispatch (UnityEngine.UIElements.BaseVisualElementPanel panel) (at <085559680b9141e8b8c144c684aaa6d7>:0)
UnityEngine.UIElements.UIElementsUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at <085559680b9141e8b8c144c684aaa6d7>:0)
UnityEngine.GUIUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at <1006e0a2a62b4fc092e72663bea815ca>:0)
UnityEditor.PopupCallbackInfo:SetEnumValueDelegate(Object, String[], Int32)
 
I just tried to reproduce this but wasn't able to. Do you get the same error if you try again in a fresh project with the latest Behavior Designer version?
 
I have the same issue and found out that it only occurs when using the last variable in the list of variables.

The issue occurs in the FieldInspector class in the method DrawSharedVariable.

It should go into that branch of the if statement but doesn't:

C#:
else if (index < names.Length - 1)
{
    sharedVariable = globalStartIndex == -1 || index < globalStartIndex ? FieldInspector.behaviorSource.GetVariable(names[index]) : GlobalVariables.Instance.GetVariable(names[index].Substring(8, names[index].Length - 8));
}

Note: This is decompiled code and might not match the real one.
 
I'm seeing a very similar (if not the same error) on version 1.6.6 with identical reproduction steps.

Code:
MissingMethodException: Cannot create an abstract class 'BehaviorDesigner.Runtime.SharedVariable'.
System.RuntimeType.CreateInstanceMono (System.Boolean nonPublic) (at <437ba245d8404784b9fbab9b439ac908>:0)
System.RuntimeType.CreateInstanceSlow (System.Boolean publicOnly, System.Boolean skipCheckThis, System.Boolean fillCache, System.Threading.StackCrawlMark& stackMark) (at <437ba245d8404784b9fbab9b439ac908>:0)
System.RuntimeType.CreateInstanceDefaultCtor (System.Boolean publicOnly, System.Boolean skipCheckThis, System.Boolean fillCache, System.Threading.StackCrawlMark& stackMark) (at <437ba245d8404784b9fbab9b439ac908>:0)
System.Activator.CreateInstance (System.Type type, System.Boolean nonPublic) (at <437ba245d8404784b9fbab9b439ac908>:0)
...

This is also when attempting to set a shared parameter value on a `Has Received Event` task
 
I don't remember this issue specifically but I am unable to repro it in the latest version. Can you send a small repro scene to support@opsive.com and I'll be able to take a look?
 
Yes, I think that I just fixed that a couple of days ago. If you send an email to support@opsive.com with your invoice and Unity version I can send you the fixed version.
 
Top