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); } }
/// <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); }
public UGOPool CreatePool(string groupName, string assetPath, UGOTemplateType itemType, GameObject template) { UGOPoolGroup group = CreateGroup(groupName); return(group.CreatePool(assetPath, itemType, template)); }