[Bug] Custom nodes with SharedVariable throw exception when using asmdef

Keerpich

New member
I have the following custom Action.

C#:
public class PrepareAttack : Action {
    [SerializeField] private SharedVariable<Unit> _attacker;
    [SerializeField] private SharedVariable<AttackConfig> _attack;

    public override void OnStart() {
        _attacker.Value.PrepareAttack(_attack.Value);
    }
}

I want to use Unity's Test Framework so I need to put my code under an .asmdef file.
However, if I do this I get the following exception when selecting the PrepareAttack node in my BT.

NullReferenceException: Object reference not set to an instance of an object
Opsive.GraphDesigner.Editor.Controls.SharedVariableControl.AddSharedVariables (Opsive.GraphDesigner.Runtime.Variables.ISharedVariableContainer container, Opsive.GraphDesigner.Runtime.Variables.SharedVariable sharedVariable, System.Boolean showAllVariables, System.Type overrideType, System.Collections.Generic.List`1[T] list, System.Int32& selectedIndex) (at <73590e06fe294f17bc5aca88bb8555c9>:0)
Opsive.GraphDesigner.Editor.Controls.SharedVariableControl.GetAllSharedVariables (Opsive.GraphDesigner.Runtime.IGraph graph, Opsive.GraphDesigner.Runtime.Variables.SharedVariable sharedVariable, System.Boolean addDynamicSelection, System.Type overrideType, System.Int32& selectedIndex) (at <73590e06fe294f17bc5aca88bb8555c9>:0)
Opsive.GraphDesigner.Editor.Controls.SharedVariableControl.GetControl (Opsive.Shared.Editor.UIElements.Controls.Types.TypeControlBase+TypeControlInput input) (at <73590e06fe294f17bc5aca88bb8555c9>:0)
Opsive.Shared.Editor.UIElements.Controls.Types.TypeControlBase.GetTypeControl (Opsive.Shared.Editor.UIElements.Controls.Types.TypeControlBase+TypeControlInput input) (at <beaa6e8967b54621bd6004fdfbefb407>:0)
....
UnityEngine.GUIUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr, System.Boolean& result) (at <e9dc32e8e55e45caa0a2bc53fe1a1c13>:0)

Is there any viable workaround or is a solution coming anytime soon?

LE: I'm using Behavior Designer Pro
 
Are Unit and AttackConfig MonoBehaviours or regular classes/structs? I just created the following within its own assembly definition and I didn't get any errors:

Code:
using Opsive.GraphDesigner.Runtime.Variables;
using using Opsive.GraphDesigner.Runtime.Tasks.Actions.Action;
using UnityEngine;

public class Unit 
{
    public int Test;
}

public class MyUnit : Action
{
    public SharedVariable<Unit> test;

}
 
I changed my custom Unit class to a MonoBehaviour and it still worked. Can you list the steps to reproduce from a fresh project?
 
I tried to repro the issue on a new project and I couldn't. As a result I thought it might have been fixed in a newer version.
I updated my package to the latest version and it worked.

Thank you!
 
Back
Top