Esempio n. 1
0
 /*
  * Initializes the dictionary scriptable object and starts the tree's execution
  */
 public void Start()
 {
     treeDataDict = (TreeDict)ScriptableObject.CreateInstance(typeof(TreeDict));
     if (StartNode)
     {
         StartCoroutine(StartNode.Execute());
     }
 }
Esempio n. 2
0
        /*
         * This is the static generic factory constructor for all TreeNodes (including all subclass nodes. It sets up the basic variables for each
         * that all nodes share, and returns the node. Nodes may override the empty constructor if they need something to be instantiated
         * there, or use Awake() or the above setup().
         *
         * Parameters:
         * parent: The parent of the TreeNode to be created
         * name: The name of the node to be created
         * gameObj: The gameObj to attach the new node to
         * treeDict: A reference to the scriptable object that contains the tree's dictionary
         *
         * Returns:
         * The generic TreeNode requested when the function was called
         */
        public static T createNode <T>(ParentNode parent, string name, GameObject gameObj, TreeDict treeDict) where T : class, new()
        {
            TreeNode node = (TreeNode)gameObj.AddComponent(typeof(T));

            node.Parent       = parent;
            node.NodeName     = name;
            node.TreeDataDict = treeDict;
            node.hideFlags    = HideFlags.HideInInspector;
            return(node as T);
        }