private void DeleteResourceHandleAsync(ref LightingEffectResHandleInstance instance, System.Action <LightingEffectResHandleInstance> callBack) { if (null == instance) { return; } int effectID = instance.EffectID; LightingEffectResHandle node = AllocResourcesHandle(effectID); node.CacheInstance(instance, EffectCacheRoot.transform, CachePos); int refCount = node.Release(); if (refCount <= 0) { //移除回调 RemoveAllCallBack(effectID); //看看是否加载完成 if (m_LightEffectHandleTable.Contains(effectID)) { m_LightEffectHandleTable.Remove(effectID); } PushToCache(node); //else //{ // //没有加载完成的直接卸载了 // UnLoadResourceHandle(node); //} } else { RemoveCallBack(effectID, callBack); } }
private bool PreWarmEffect(int nID, int PreWarmCount) { if (m_allBehaviorTable.ContainsKey(nID)) { //Debug.LogWarning("光效已经加载,不需要缓存,ID:" + nID); return(false); } LightingEffect config = ASpeedGame.Data.Scheme.SchemeLightingEffect.Instance.GetLightingEffect(nID); if (!config) { Debug.LogWarning("光效加载失败,找不到配置,ID:" + nID); return(false); } LightingEffectResHandle handle = AllocResourcesHandle(nID); Queue <LightingEffectBehavior> list = null; if (!m_behaviorCacheTable.TryGetValue(nID, out list)) { list = new Queue <LightingEffectBehavior>(); m_behaviorCacheTable.Add(nID, list); } for (int i = 0; i < PreWarmCount; i++) { LightingEffectBehavior reslut = CreateNewBehavior(nID, config.GetEffectType()); LightingEffectResHandleInstance instance = GetResourceHandleAsync(nID, reslut.OnResourcesLoadFinish); handle.CacheInstance(instance, EffectCacheRoot.transform, CachePos); handle.Release();//缓存不需要保留引用 reslut.FillData(config, null, instance, null); list.Enqueue(reslut); } return(true); }
public void ResetBehavior(LightingEffectBehavior instance) { if (!isValid) { return; } if (null == instance) { return; } int effectID = instance.getID(); if (effectID > 0) { LightingEffectResHandle handle = AllocResourcesHandle(instance.getID()); handle.CacheInstance(instance.ResourceHandle, EffectCacheRoot.transform, CachePos); handle.Release(); } DeleteBehaviorTransformAgent(instance.TransformAgent); //CacheBehaviorDestroyTimer(instance.BehaviorDestroyTimer); instance.ResetAllMembers(); instance.SetInvalid(); }