Example #1
0
        public override void OnBeforeSerialize(BTAsset btAsset)
        {
            base.OnBeforeSerialize(btAsset);

            if (string.IsNullOrEmpty(m_behaviourTreeID))
            {
                m_behaviourTreeID = BTUtils.GenerateUniqueStringID();
            }

            btAsset.SetSubtreeAsset(m_behaviourTreeID, m_behaviourTreeAsset);
        }
Example #2
0
        public virtual void OnBeforeSerialize(BTAsset btAsset)
        {
            guid = BTUtils.GenUniqueGUID();

            foreach (var constraint in m_constraints)
            {
                constraint.OnBeforeSerialize(btAsset);
            }
            foreach (var service in m_services)
            {
                service.OnBeforeSerialize(btAsset);
            }
        }
Example #3
0
        public virtual BehaviourTree CreateRuntimeTree()
        {
            BehaviourTree tree = BTUtils.DeserializeTree(m_serializedData);

            if (tree == null)
            {
                tree = new BehaviourTree();
            }

            tree.Root.OnAfterDeserialize(this);
            tree.ReadOnly = true;
            return(tree);
        }
Example #4
0
        public virtual void Serialize()
        {
            if (m_editModeTree != null)
            {
                treeUidString              = m_editModeTree.guidString;
                m_editModeTree.title       = title;
                m_editModeTree.description = description;

                lastFileName = this.name;

                m_editModeTree.Root.OnBeforeSerialize(this);

                string serializedData = BTUtils.SerializeTree(m_editModeTree);
                if (serializedData != null)
                {
                    m_serializedData = serializedData;
                }
            }
        }
Example #5
0
        public virtual BehaviourTree GetEditModeTree()
        {
            string nm = this.name;

            if (m_editModeTree == null)
            {
                m_editModeTree = BTUtils.DeserializeTree(m_serializedData);
                if (m_editModeTree != null)
                {
                    if (string.IsNullOrEmpty(m_editModeTree.guidString) || lastFileName != this.name)
                    {
                        m_editModeTree.guidString = BTUtils.GenerateUniqueStringID();
                    }
                    m_editModeTree.Root.OnAfterDeserialize(this);
                    m_editModeTree.ReadOnly = false;
                }
            }

            return(m_editModeTree);
        }
Example #6
0
        public BehaviourTree CreateRuntimeSubTree(int subTreeIndex)
        {
            if (subTreeIndex < 0 || subTreeIndex >= indexedSubTrees.Length)
            {
                return(null);
            }

            if (indexedSubTrees[subTreeIndex] == null)
            {
                return(null);
            }

            BehaviourTree tree = BTUtils.DeserializeTree(indexedSubTrees[subTreeIndex].SerializedData);

            if (tree == null)
            {
                tree = new BehaviourTree();
            }

            tree.Root.OnAfterDeserialize(indexedSubTrees[subTreeIndex]);
            tree.ReadOnly = true;
            return(tree);
        }