コード例 #1
0
        public T Recreate <T>(UnityNodeBase parentNode, PCFResourceType loadFlags) where T : UnityNodeBase
        {
            UnityNodeBase recreatedNode = null;

            //Allows us to mask nodes to load, makes it easier to do quick lookup of specific things. (like reading script data, no need to load textures etc)
            if ((this.resourceType & loadFlags) != 0)
            {
                //Create implementation specific node based on typetree info.
                recreatedNode = nodeFactory.CreateNodeImplementation(this.nodeName, this.resourceType, this.referenceID);
            }

            //If we are not the root node we will have a parent.
            if (parentNode != null && recreatedNode != null)
            {
                parentNode.AddChildNode(recreatedNode);
            }

            if (this.childNodes != null)
            {
                for (int i = 0; i < this.childNodes.Count; i++)
                {
                    this.childNodes[i].Recreate <T>(recreatedNode, loadFlags);
                }
            }

            //Only true for root node.
            if (parentNode == null)
            {
                return(recreatedNode as T);
            }

            return(null);
        }