/// <summary> /// Call this to load nodes. /// <param name="gameObject">The target game object.</param> /// <param name="nodeOwner">The node owner.</param> /// </summary> public ActionNode[] LoadNodes (GameObject gameObject, INodeOwner nodeOwner) { var nodes = new List<ActionNode>(); m_BranchChildren = new Dictionary<int, List<ActionNode>>(); // Validate parameters if (gameObject == null || nodeOwner == null ) return nodes.ToArray(); m_GameObject = gameObject; m_NodeOwner = nodeOwner; m_Blackboard = gameObject.GetComponent<InternalBlackboard>(); // Goes through all node types and creates an instance for (int i = 0; i < m_NodeTypes.Count; i++) { ActionNode node = Load(nodes, i); // It's a valid node? if (node != null) nodes.Add(node); } // Add children to branch foreach (var pair in m_BranchChildren) { var branch = nodes[pair.Key] as BranchNode; if (branch == null || !branch.SetChildren(m_BranchChildren[pair.Key].ToArray())) nodeOwner.HierarchyChanged(); } m_BranchChildren = null; return nodes.ToArray(); }