Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="eType"></param>
        /// <param name="prefab">源资源prefab</param>
        /// <returns></returns>
        private NodeObject CreateEmptyNode(eNodeType eType, UnityEngine.Object prefab)
        {
            if (prefab == null)
            {
                return(null);
            }

            NodeObject node = null;
            GameObject go   = GameObject.Instantiate(prefab) as GameObject;

            go.name = prefab.name;

            switch (eType)
            {
            case eNodeType.Normal:
                node = go.GetComponent <NormalNode>();
                if (node == null)
                {
                    node = go.AddComponent <NormalNode>();
                }
                node.eType = eNodeType.Normal;
                break;

            case eNodeType.Len:
                node = go.GetComponent <NormalNode>();
                if (node == null)
                {
                    node = go.AddComponent <NormalNode>();
                }
                node.eType = eNodeType.Len;
                break;

            case eNodeType.Combine:
                node = go.GetComponent <NormalNode>();
                if (node == null)
                {
                    node = go.AddComponent <NormalNode>();
                }
                node.eType = eNodeType.Combine;
                break;

            default:
                node = go.GetComponent <NormalNode>();
                if (node == null)
                {
                    node = go.AddComponent <NormalNode>();
                }
                node.eType = eNodeType.Normal;
                break;
            }

            node.Init();

            node.SetParent(cacheRoot);

            //node.SetActive(false);

            return(node);
        }
Esempio n. 2
0
        public void RecoverNode(NodeObject node)
        {
            eNodeType         eType = node.eType;
            int               mType = (int)eType;
            List <NodeObject> list  = null;

            if (!_nodePool.TryGetValue(mType, out list))
            {
                GameObject.Destroy(node);

                Debug.LogError("RecoverNode failed not contain this type pool");
                return;
            }

            node.Disappear();

            node.SetParent(cacheRoot);

            node.position = Vector3.zero;

            list.Add(node);
        }