void Loaded(CSResource res) { if (!mLoadedDic.ContainsKey(res.Key)) { return; } ModelLoadData data = mLoadedDic[res.Key]; GameObject go = res.MirrorObj as GameObject; if (go == null) { LoadedOne(res); return; } data.atlas = go.GetComponent <SFAtlas>(); if (data.atlas != null) { data.atlas.ResPath = res.Path; } AtlasPoolItemDeal(data.atlas); if (FlagFinish(res.Key) && IsAllFinish())//如果FlagFinish成功,表示是最新的,如果由于动作切换太快,后面的动作比前面动作加载快,那么Loaded都会调用,但是onFinishAll之后后面的动作到了之后才会调用 { CallOnFinishAll(); //else //{ // Debug.Log("onFinishAll is Null = "); //} } else { LoadedOne(res); } }
protected virtual void BeginLoadRes() { for (int i = 0; i < mObjectList.Count; i++) { long key = mObjectList[i]; ModelLoadData data = mLoadedDic[key]; string path = SFOut.IResourceManager.GetKeyPath(key); if (!string.IsNullOrEmpty(path)) { AddHasUseModelResList(path); CSResource res = SFOut.IResourceManager.AddQueue(path, data.type, Loaded, data.assistType, true, key); BeginLoadModelResCallBack(res); } else { int modelID = 0, motion = 0, direction = 0; SplitKey(key, ref modelID, ref motion, ref direction); string Model = GetCombineModel((uint)modelID, (uint)motion, (uint)direction); path = CSResource.GetPath(Model, data.type, false); AddHasUseModelResList(path); SFOut.IResourceManager.AddKeyPath(key, path); //Debug.Log(Model + " " + type+" TimeCount = "+Time.frameCount); CSResource res = SFOut.IResourceManager.AddQueue(path, data.type, Loaded, data.assistType, true, key); BeginLoadModelResCallBack(res); } } }
public static void LoadModelInQueue(string modelName, LoadSingleFinish delFinish, object param1, object param2, object param3) { ModelLoadData curData = new ModelLoadData(ModelLoadData.LoadType.MODEL, modelName, delFinish, param1, param2, param3); if (m_dicSingleBundleCache.ContainsKey(curData.GetLoadUrl())) { if (null != delFinish) { delFinish(modelName, m_dicSingleBundleCache[curData.GetLoadUrl()], param1, param2, param3); } return; } m_loadBundleQueue.Enqueue(curData); }
public static void BundleQueueLoadTick(MonoBehaviour bundleLoader) { if (null == bundleLoader) { return; } while (m_loadBundleQueue.Count > 0) { ModelLoadData curData = m_loadBundleQueue.Dequeue(); if (null != curData) { bundleLoader.StartCoroutine(LoadOneBundleFromQueue(curData)); } } TryUnloadUnuseBundle(); }
private static IEnumerator LoadOneBundleFromQueue(ModelLoadData curData) { string bundlePath = curData.GetLoadUrl(); if (!LoadFromCache(bundlePath, curData.m_modelName, curData.m_delFinish, curData.m_param1, curData.m_param2, curData.m_param3)) { #if UNITY_WP8 while (m_SingleBundleLoadingList.Contains(bundlePath)) { yield return(null); } if (m_dicSingleBundleCache.ContainsKey(bundlePath)) { if (null != curData.m_delFinish) { curData.m_delFinish(bundlePath, m_dicSingleBundleCache[bundlePath], curData.m_param1, curData.m_param2, curData.m_param3); } yield break; } if (!m_SingleBundleLoadingList.Contains(bundlePath)) { m_SingleBundleLoadingList.Add(bundlePath); WWW www = new WWW(bundlePath); yield return(www); ProcessLoad(www, bundlePath, curData.m_modelName, curData.m_delFinish, curData.m_param1, curData.m_param2, curData.m_param3); m_SingleBundleLoadingList.Remove(bundlePath); } #else WWW www = new WWW(bundlePath); yield return(www); ProcessLoad(www, bundlePath, curData.m_modelName, curData.m_delFinish, curData.m_param1, curData.m_param2, curData.m_param3); #endif } }
public void Load(uint modelID, uint motion, uint direction, uint structure, ResourceType type, ResourceAssistType assistType) { //Debug.Log(modelID + " " + motion + " " + direction); if (SFOut.IResourceManager == null) { return; } long key = GetKey((int)modelID, (int)motion, (int)direction); //if (avater != null && avater.getAvatarType() == EAvatarType.MainPlayer) //{ // Debug.Log("motion = " + (CSMotion)motion); //} if (mLoadedDic.ContainsKey(key)) { ModelLoadData data = mLoadedDic[key]; if (data != null && data.atlas != null && !data.atlas.HasBeenDestroy) { mStructures[structure] = key; string path = SFOut.IResourceManager.GetKeyPath(key); CSResource res = SFOut.IResourceManager.GetRes(path); if (res != null) { BeginLoadModelResCallBack(res); } return; } } else { ModelLoadData data = new ModelLoadData(); mLoadedDic.Add(key, data); data.type = type; data.assistType = assistType; } mStructures[structure] = key; mObjectList.Add(key); mObjectFinishStateList.Add(false); }
public void GetWaitModelRes() { for (int i = 0; i < mObjectList.Count; i++) { long key = mObjectList[i]; if (!mLoadedDic.ContainsKey(key)) { continue; } int modelID = 0, motion = 0, direction = 0; SplitKey(key, ref modelID, ref motion, ref direction); ModelLoadData data = mLoadedDic[key]; string path = SFOut.IResourceManager.GetKeyPath(key); if (SFOut.IResourceManager == null) { return; } if (!string.IsNullOrEmpty(path)) { CSResource res = SFOut.IResourceManager.GetRes(path); if (res != null && res.IsCanBeDelete) { SFOut.IResourceManager.RemoveWaitingQueueDic(res.Path); } } else { string Model = GetCombineModel((uint)modelID, (uint)motion, (uint)direction); path = CSResource.GetPath(Model, data.type, false); CSResource res = SFOut.IResourceManager.GetRes(path); if (res != null && res.IsCanBeDelete) { SFOut.IResourceManager.RemoveWaitingQueueDic(res.Path); } } } }