示例#1
0
        void Awake()
        {
            _trees.Clear();

            var btComps = FindObjectsOfType <BonsaiTreeComponent>();

            foreach (BonsaiTreeComponent btc in btComps)
            {
                BehaviourTree blueprint = btc.TreeBlueprint;

                if (blueprint)
                {
                    var tree = BehaviourTree.Clone(blueprint);
                    tree.actor = btc.gameObject;
                    btc.bt     = tree;

                    _trees.Add(tree);
                }

                else
                {
                    Debug.LogError("The associated behaviour tree is null.");
                }
            }
        }
示例#2
0
        public static void AddTree(BehaviourTree blueprint)
        {
            var btInstance = BehaviourTree.Clone(blueprint);

            btInstance.Start();

            _trees.Add(btInstance);
        }
 void Awake()
 {
     if (TreeBlueprint)
     {
         treeInstance       = BehaviourTree.Clone(TreeBlueprint);
         treeInstance.actor = gameObject;
     }
     else
     {
         Debug.LogError("The behaviour tree is not set for " + gameObject);
     }
 }