Behavior Node Variables - Expose Custom Types and SO to Inspector?

Good morning.

I try to expose some ScriptableObject field and other custom serializable classes to the Inspector inside Behavior Node Editor. Not as a Blackboard variable but Locally to the node.
In my example screenshot :

  • “AiTagSO” (used by the node to choose inside a list of possible game actions inside another component)
  • “AiComputeData” (to prioritize one action when different game actions are found).

But the only way I found is to make a blackboard variable field and set it to private.
I am really afraid of the quickly escalating blackboard with tens or hundred of variables.

So I was wondering if I can just expose a field the “regular way” ?
Or maybe it’s possible to sort the blackboard variable into folders ?

  • I tried to override OnInspectorGUI(), but the node editor seems to have it’s own editor gui.

Here is what I understand of variable exposure inside the graph :

///What I understand :

//Expose the field in graph inspector as some sort of polymorphic type for generic types
//Most of the values can be set localy or by a blackboard 
variable, but some only by blackboard variable :(
[SerializeReference] public BlackboardVariable<Type> Name;

//Private to the node
private Type m_name;

//Doesn't do anything in that context (what I want to expose locally to my node)
[SerializeField] private Type m_name;

//Private to the whole graph
[CreateProperty]
private Type m_name;

My custom serializable class

    /// <summary>
    /// Data to help AI decide if and how it should use a Game Action
    /// </summary>
    [Serializable]
    public class ActionAiComputeData
    {
        [SerializeField] private float weight = 1f;

        [SerializeField] private bool requireGetInRange = true;
        [SerializeField] private float minDistanceFromtarget = 0f;
        [SerializeField] private float maxDistanceFromtarget = 1.5f;

        //other properties to filter actions
        //...
        //...
    }

My node

///
...
///
public partial class ChooseAction : Action
{
    [SerializeField] public bool test;
    [SerializeField] public ActionAiTagSO aiTag;
    [SerializeReference] public BlackboardVariable<ActionAiTagSO> aiTagSO;

    [SerializeField] public ActionAiComputeData aiData;
    [SerializeReference] public BlackboardVariable<ActionAiComputeData> aiComputeData;
///
...
...
...
///
}

Thanks in advance for any guidance !

Hey @Vroyevn,

Good morning!

Looks like what you are trying to achieve is the use of plain data serialization in the insepctor.

This is something on our radar that we plan to do & have a task for it, but it may take a little time to get it all working and released.

Right now unfortunately there is no easy way to achieve this but there will be in the future!

Your examples were all correct except one. I noticed that you misunderstood the
[CreateProperty] attribute.
This is actually used for runtime serializtion to save & load graphs. You can find examples in our runtime serialization sample.

I hope that helps for now!

Hello @Darren_Kelly,

Thank you for your kick answer.

Awesome. So official support is planned for that feature.
I take note and I’ll work with some work-around.
Will follow the updates of that package :slight_smile:

.

[CreatePropety]
Oh I see. In the sample it is used as a save and load of agents positions/state.

So if I understand the intended process to make a Variable //Private but accessible to the whole graph :
i guess I should rather make a blackboard variable and set it to Not Exposed in the blackboard. Is that correct ?

Thanks for your support

Exactly yes! You can set the flag here so that it’s not exposed.

Any update on this? I’m trying to hook into my own C# EventSystem from Behavior Graph, but I can’t find a way to expose custom types.

Hi @theghostronaut

Behavior package doesn’t support plain old data atm. Only Unity.Object objects can be serialized using BlackboardVariable.

Sorry for the inconvenience :bowing_man:

please make this bigger prioriity or at least allow us to create custom drawers for nodes, its very important feauture that is missing since long time