public ModelCfg GetModelCfg(int modelId) { if(modelId == 88) { if(null == model88) { model88 = new ModelCfg(); model88.Id = 88; model88.FilePath = AssetPath.GetAssetStorePathWithSlash() + "Characters/weapon/we0088/we0088_1.unity3d"; } return model88; } if(modelId == 9) { if(null == model09) { model09 = new ModelCfg(); model09.Id = 9; model09.FilePath = AssetPath.GetAssetStorePathWithSlash() + "Characters/npc/so0009/so0009_1.unity3d"; model09.MtrlList = new List<ModelMtrl>(); ModelMtrl mtrl = new ModelMtrl(); mtrl.Name = "so0009"; mtrl.TexList = new List<MtrlTex>(); mtrl.TexList.Add(new MtrlTex("_MainTex", AssetPath.GetAssetStorePathWithSlash() + "Characters/npc/so0009/so0009.unity3d")); mtrl.TexList.Add(new MtrlTex("_ClothTex", AssetPath.GetAssetStorePathWithSlash() + "Characters/npc/so0009/so0025_cloth.unity3d")); model09.MtrlList.Add(mtrl); } return model09; } if(modelId == 111) { if(null == model111) { model111 = new ModelCfg(); model111.Id = 111; model111.FilePath = AssetPath.GetAssetStorePathWithSlash() + "h1_ho0001.unity3d"; } return model111; } return null; }
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 SetModelCfg(ModelCfg cfg) { modelCfg = cfg; InitModel(); }
/* 只给一个文件名,就只能模拟一个数据,然后加载 */ public void LoadModel(string modelPath, ResParamLoadCallBack<Model> loadCB, ResLoadProgressCallBack progressCB, object userParam) { ModelCfg cfg = new ModelCfg(); cfg.FilePath = modelPath; LoadModel(cfg, loadCB, progressCB, userParam); }
public ModelCfgLoadParam(ResParamLoadCallBack<Model> cb, ModelCfg cfg, string filePath, object param) { this.cb = cb; this.cfg = cfg; this.filePath = filePath; this.userParam = param; }