void Awake() { rootNode = GetComponent <Root>(); if (rootNode == null) { Debug.LogWarning("Missing Root node in behaviour tree.", this); } // Find master parent tree and all nodes MonoBehaviourTree masterTree = this.GetMasterTree(); Node[] nodes = GetComponents <Node>(); if (masterTree == this) { // Create lists with capicity executionStack = new List <Node>(8); executionLog = new List <Node>(nodes.Length); // Set start node when tree is created first time executionStack.Add(rootNode); executionLog.Add(rootNode); } // Initialize nodes of tree/subtree for (int i = 0; i < nodes.Length; i++) { Node n = nodes[i]; n.behaviourTree = masterTree; n.runningNodeResult = new NodeResult(Status.Running, n); } }
void OnValidate() { if (monoBehaviourTree != null && monoBehaviourTree.parent != null) { monoBehaviourTree = null; Debug.LogWarning("Subtree should not be target of update. Select parent tree instead.", this.gameObject); } }
void OnValidate() { if (maxExecutionsPerTick <= 0) { maxExecutionsPerTick = 1; } if (parent != null) { if (parent == this) { parent = null; Debug.LogWarning("This tree cannot be its own parent."); return; } if (transform.parent == null || parent.gameObject != transform.parent.gameObject) { // parent = null; Debug.LogWarning("Parent tree should be also parent of this gameobject.", this.gameObject); } } }
void Reset() { monoBehaviourTree = GetComponent <MonoBehaviourTree>(); OnValidate(); }