I’m implementing a save/load system for my real-time game. Since the game is real-time, I need to be able to save and restore the state of behavior tree of my characters.
The state of a behaviour tree can not be stored entirely as-is. However, the best solution to save/load the state of your characters behaviour tree is to save and load the blackboard variables that the tree is using instead. Then based on these variables and the design of the tree, the flow can be directed towards the branch you need the tree to follow and as such effectively restoring the state of the tree (mostly meaning which leaf node is currently Running).
The variables of the Blackboard component attached on the gameobject (alongside BehaviourTreeOwner) can be saved and loaded through the Serialize and Deserialize methods it has. Blackboard.Serialize will return a json string (which will of course need to be stored somewhere like a text file or Unitys PlayerPrefs), and the Blackboard.Deserialize method takes a string parameter where you basically pass the previously saved json.