How to access BehaviorTree's reference variable (e.g SharedGameObject) outside of play mode?

Leonm

New member
NOTE: Still haven't updated to PRO

Hi there!

TL;DR: Need to access ref variables of individual BehaviorTree instances in the editor. But in the editor I can only see the ExternalBehaviorTree asset's variables, which has only values like int, float, string. No reference like SharedGameObject, etc.

1. My BehaviorTree (BT) has a SharedGameObject variable name myBTVar, with a value assigned to it in the BT's Inspector.
2. The BT has a Task (MyTask) that has a public SharedGameObject called myVar with the myBTVar selected.
3. MyTask has a custom object drawer that needs to access the myVar, which points to the BT's myBTVar.
4. In the editor, myBTVar is null. It seems like it's getting the values from the ExternalBehaviorTree BT, which doesn't hold any references. The references, like SharedGameObject, are in the instances of BehaviorTree that uses that ExternalBehavior.
5. Weird thing is, if I rename the myBTVar, something is triggered and I can suddenly get all the values in the editor.

It's been 2 days that I'm trying everything. Can someone, please, help me?
 
On the BehaviorTree component you can call GetVariable. This will deserialize the tree no matter if you are in runtime or edit mode.
 
Back
Top