/// <summary> /// 进行特效的预加载,并创建缓存池 /// </summary> /// <param name="poolData"></param> //public void PreloadEffect(PoolData poolData) //{ // PoolManager.GetInstance().CreateGameObjectPool(poolData); //} // public void PreloadEffect(string spawnName, string assetPath, int preloadCount, OnPoolPreloadComplete callback) // { // PoolData poolData = new PoolData() // { // spawnName = spawnName, // assetPath = assetPath, // preloadTotalAmount = preloadCount, // preloadCompleteCallback = callback, // }; // PreloadEffect(poolData); // } /// <summary> /// 获取指定的特效,并创建其对应的缓存池, 特效释放后会被回收到池中 /// </summary> /// <param name="spawnName"></param> /// <param name="assetPath"></param> /// <param name="isAutoRelease"></param> /// <returns></returns> public EffectController CreateEffect(string assetPath, string spawnName = "", OnEffectLoaded OnEffectLoaded = null, System.Object usedata = null) { EffectController effectController = effectControllerPool.GetComponentItem <EffectController>(); effectController.CachedTransform.SetParent(rootTransform); effectController.CachedTransform.localPosition = Vector3.zero; effectController.CachedTransform.localRotation = Quaternion.identity; effectController.CachedTransform.localScale = Vector3.one; effectController.Initialize(assetPath, spawnName, OnEffectLoaded, usedata); return(effectController); }
/// <summary> /// 获取指定的特效,并创建其对应的缓存池, 特效释放后会被回收到池中 /// </summary> /// <param name="spawnName"></param> /// <param name="assetPath"></param> /// <param name="isAutoRelease"></param> /// <returns></returns> public EffectController CreateEffectByInstantiateAsset(string assetPath, Transform parent, Vector3 localPosition, Quaternion localRotation, Vector3 localScale, string spawnName = "") { EffectController effectController = effectControllerPool.GetComponentItem <EffectController>(); effectController.CachedTransform.SetParent(parent, false); effectController.CachedTransform.localPosition = localPosition; effectController.CachedTransform.localRotation = localRotation; effectController.CachedTransform.localScale = localScale; effectController.InitializeByInstantiateAsset(assetPath); return(effectController); }
public void OnDestroyEffect(EffectController effect) { effectControllerPool.RemoveItemFromUnusedList(effect.gameObject); }