public void LoadAnimation(string animPath, ResParamLoadCallBack<AnimationClip> loadCB, ResLoadProgressCallBack progressCB, object userParam) { if(string.IsNullOrEmpty(animPath)) return; ResCounter<AnimationClip> res = null; if(m_dictAnimationClip.ContainsKey(animPath)) { res = m_dictAnimationClip[animPath]; if(null != res.Res) { res.AddRef(); if(null != progressCB) progressCB(animPath, 1f, userParam); if(null != loadCB) loadCB(animPath, res.Res, userParam); return; } } else { //get path res = new ResCounter<AnimationClip>(); res.ResPath = animPath; m_dictAnimationClip.Add(animPath, res); m_listLoadingList.AddLast(res); } res.AddRef(); if(null != loadCB || null != progressCB) { res.AddLoadParam(userParam, loadCB, progressCB); } }
public void LoadEffect(string fxPath, ResParamLoadCallBack<GameObject> loadCB, ResLoadProgressCallBack progressCB, object userParam) { if(string.IsNullOrEmpty(fxPath)) return; ResCounter<GameObject> res = null; if(m_dictGameObject.ContainsKey(fxPath)) { res = m_dictGameObject[fxPath]; if(null != res.Res) { res.AddRef(); if(null != progressCB) progressCB(fxPath, 1f, userParam); if(null != loadCB) loadCB(fxPath, res.Res, userParam); return; } } else { //get path res = new ResCounter<GameObject>(); res.ResPath = fxPath; m_dictGameObject.Add(fxPath, res); m_listLoadingList.AddLast(res); } res.AddRef(); if(null != loadCB || null != progressCB) { res.AddLoadParam(userParam, loadCB, progressCB); } }
/* 只给一个Id,就只能获取数据,然后加载 */ public void LoadModel(int modelId, ResParamLoadCallBack<Model> loadCB, ResLoadProgressCallBack progressCB, object userParam) { ModelCfg cfg = ResMgr.Instance.GetModelCfg(modelId); if(null == cfg) return; LoadModel(cfg, loadCB, progressCB, userParam); }
void LoadModel(ModelCfg cfg, ResParamLoadCallBack<Model> loadCB, ResLoadProgressCallBack progressCB, object userParam) { if(null == cfg) return; // add to list first m_listModelCfg.Add(new ModelCfgLoadParam(loadCB, cfg, cfg.FilePath, userParam)); ResCounter<GameObject> res = null; if(m_dictModel.ContainsKey(cfg.FilePath)) { res = m_dictModel[cfg.FilePath]; if(null != res.Res) { res.AddRef(); //if(null != progressCB) res.ProgressCallBack += progressCB; //if(null != loadCB) res.LoadCallBack += loadCB; if(null != progressCB) progressCB(res.ResPath, 1f, userParam); OnAssetOK(res); return; } else { if(null != res.Bundle) { //if(null != loadCB) res.LoadCallBack += loadCB; //if(null != progressCB) res.ProgressCallBack += progressCB; if(null != progressCB) progressCB(res.ResPath, 1f, userParam); OnAssetLoadCallBack(true, res); return; } } } else { //get path res = new ResCounter<GameObject>(); res.ResPath = cfg.FilePath; m_dictModel.Add(cfg.FilePath, res); } res.AddRef(); m_listLoadingList.AddLast(res); if(null != progressCB) { res.AddLoadParam(userParam, null, progressCB); } }
public void LoadTexture(string filePath, ResParamLoadCallBack<Texture2D> loadCB, ResLoadProgressCallBack progressCB, object userParam) { if(string.IsNullOrEmpty(filePath)) return; // add to list first ResCounter<Texture2D> res = null; if(m_dictTexture.ContainsKey(filePath)) { res = m_dictTexture[filePath]; if(null != res.Res) { res.AddRef(); //if(null != progressCB) res.ProgressCallBack += progressCB; //if(null != loadCB) res.LoadCallBack += loadCB; if(null != progressCB) progressCB(res.ResPath, 1f, userParam); if(null != loadCB) loadCB(res.ResPath, res.Res, userParam); return; } /* 如果丢失的话,重新加载,并且清理一下无用资源,防止泄露 */ m_dictTexture.Remove(filePath); Resources.UnloadUnusedAssets(); } else { //get path res = new ResCounter<Texture2D>(); res.ResPath = filePath; m_dictTexture.Add(filePath, res); } res.AddRef(); m_listLoadingList.AddLast(res); //if(null != loadCB) res.LoadCallBack += loadCB; if(null != loadCB || null != progressCB) { res.AddLoadParam(userParam, loadCB, progressCB); } }
/* 只给一个文件名,就只能模拟一个数据,然后加载 */ public void LoadModel(string modelPath, ResParamLoadCallBack<Model> loadCB, ResLoadProgressCallBack progressCB, object userParam) { ModelCfg cfg = new ModelCfg(); cfg.FilePath = modelPath; LoadModel(cfg, loadCB, progressCB, userParam); }