Beispiel #1
0
        internal UGOPool(
            Transform parentTransform,
            string assetPath,
            UGOTemplateType templateType,
            GameObject templateGObj)
        {
            AssetPath          = assetPath;
            this.templateType  = templateType;
            templateGameObject = templateGObj;
            if (UGOPoolUtill.IsDebug)
            {
                poolTransform = new GameObject(assetPath).transform;
                poolTransform.SetParent(parentTransform, false);
            }
            else
            {
                poolTransform = parentTransform;
            }

            if (templateType != UGOTemplateType.Prefab)
            {
                templateGameObject.SetActive(false);
                templateGameObject.transform.SetParent(poolTransform, false);
            }
        }
Beispiel #2
0
        /// <summary>
        /// 使用给定的GameObject创建缓存池
        /// </summary>
        /// <param name="assetPath">资源唯一标签,一般使用资源路径</param>
        /// <param name="template">模板GameObject</param>
        /// <returns></returns>
        public UGOPool CreatePool(string assetPath, UGOTemplateType itemType, GameObject template)
        {
            if (template == null)
            {
                LogUtil.Error(UGOPoolUtill.LOG_TAG, "Template is Null");
                return(null);
            }
            if (poolDic.ContainsKey(assetPath))
            {
                LogUtil.Error(UGOPoolUtill.LOG_TAG, "The pool has been created.uniqueName = " + assetPath);
                return(null);
            }

            UGOPool pool = new UGOPool(groupTransform, assetPath, itemType, template);

            poolDic.Add(assetPath, pool);
            return(pool);
        }
Beispiel #3
0
        public UGOPool CreatePool(string groupName, string assetPath, UGOTemplateType itemType, GameObject template)
        {
            UGOPoolGroup group = CreateGroup(groupName);

            return(group.CreatePool(assetPath, itemType, template));
        }