Using Unity’s Graph View
EDIT: The base for this code is heavily based on The KiwiCoder’s Behavior Tree.
Behaviour Tree Editor — TheKiwiCoder
FREE Behaviour Tree Editor! ✅ Build Better AI ✅ Accelerate your prototyping ✅ Customise and extend DOWNLOAD NOW
The main difference between the 2 is the way the Style Sheet is linked and the behavior of the node inputs. The Project Files can be Found on GitHub at.
GraphViewBehaviorTree/README.md at main · JamesLaFritz/GraphViewBehaviorTree
' Report Bug · Request Feature I had code on sitting around on my hard drive for a Behavior Tree Editor That inspired…
One of the problems right now is if I move the Node around when I go back to edit the graph the nodes appear right on top of each other. To fix this I need to remember the position in the graph the node was last at.
The Node needs a Vector2 for the position it is in in the graph.
In the Behavior Tree Node View I need to override the Nodes Set Position. I set the Node’s Node Graph Position to be the X Min and Y Min of the rectangle.
Then I change the Style of the Node View Left to be the Node’s x position and the Top to be the Node’s y position.
And Now The Position is remembered.
Fixing the Selection Change On Code Reload
Now the other problem is every time I make a change to the Code Unity Reloads and I get a new Editor Window. The Window forgets what was selected and I have to select something in Unity then re-select my behavior tree. To fix this in the Behavior Tree Editor when I Create the GUI I just add a call to the On Selection Change at the end.
Now when ever the Editor Window gets Reloaded it will run the On Selection Change.