Edit ExternalBehaviorTree variables from a custom inspector

Dorcan

New member
Hello !

We've integrated Behavior Designer in our game, and I wanted to integrate exposed variables of ExternalBehaviorTree inside our own custom inspector for our enemies. That way all variables for each enemies are centralized, making it easier to use for our game designer.

Capture Custom Drawer.png
Our inspector with values from the external behavior tree

Capture External Behavior Inspector.png
The external behavior tree

However, I couldn't figure out how to save the changes in the asset. They are saved in memory alright, but when reloading scripts or reopening the project, values are reverted.

Here's an extract from my code:

Code:
                    switch (type.Name)
                    {
                        case "Int32":
                            variableValue = EditorGUI.IntField(position, variable.Name, (int)variable.GetValue());
                            position.y += lineHeight;
                            break;

                        case "Single":
                            variableValue = EditorGUI.FloatField(position, variable.Name, (float)variable.GetValue());
                            position.y += lineHeight;
                            break;

                        case "Vector2":
                            variableValue = EditorGUI.Vector2Field(position, variable.Name, (Vector2)variable.GetValue());
                            position.y += lineHeight;
                            break;
                    }

                    externalBehaviorTree.SetVariableValue(variable.Name, variableValue);
                  
                    if (EditorGUI.EndChangeCheck())
                    {
                        EditorUtility.SetDirty(externalBehaviorTree);
                        AssetDatabase.SaveAssets();
                    }


I tried with externalBehaviorTree.SetBehaviorSource(...) but no luck.
Is there any public way to edit and save exernalBehaviorTree variables from an external editor ?

Thanks for your response, and thanks for this wonderful tool ! ?
 
Happy to hear that you're enjoying Behavior Designer! Here's a post that has a code snippet for serializing the tree:

 
Top