コード例 #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);
        }
コード例 #3
0
 void Awake()
 {
     if (TreeBlueprint)
     {
         treeInstance       = BehaviourTree.Clone(TreeBlueprint);
         treeInstance.actor = gameObject;
     }
     else
     {
         Debug.LogError("The behaviour tree is not set for " + gameObject);
     }
 }