public override void OnBeforeSerialize(BTAsset btAsset) { base.OnBeforeSerialize(btAsset); if (string.IsNullOrEmpty(m_behaviourTreeID)) { m_behaviourTreeID = BTUtils.GenerateUniqueStringID(); } btAsset.SetSubtreeAsset(m_behaviourTreeID, m_behaviourTreeAsset); }
public void Serialize() { if (m_editModeTree != null) { m_editModeTree.Root.OnBeforeSerialize(this); string serializedData = BTUtils.SerializeTree(m_editModeTree); if (serializedData != null) { m_serializedData = serializedData; } } }
public BehaviourTree CreateRuntimeTree() { BehaviourTree tree = BTUtils.DeserializeTree(m_serializedData); if (tree == null) { tree = new BehaviourTree(); } tree.Root.OnAfterDeserialize(this); tree.ReadOnly = true; return(tree); }
public BehaviourTree GetEditModeTree() { if (m_editModeTree == null) { m_editModeTree = BTUtils.DeserializeTree(m_serializedData); if (m_editModeTree != null) { m_editModeTree.Root.OnAfterDeserialize(this); m_editModeTree.ReadOnly = false; } } return(m_editModeTree); }