public static void openNextScene(SceneBase scene) { Tools.Log("===> openNextScene!"); if (m_busy) { Tools.Log("next scene is busy now!"); return; } //MgrPanel.disposeAllPanel(); if (m_curScene != null) { MgrResLoader.insertRemoving(m_curScene.getResList()); m_curScene.onLeave(); m_curScene = null; } m_busy = true; PanelLoading.open(); MgrResLoader.insertLoading(scene.getResList()); m_nextScene = scene; MgrPanel.disposeAllPanel(); MgrRes.clearObjectCacheAll(); Util.ClearMemory(); MgrResLoader.start(executeSceneDown); }
public static void process(Action callback) { float total = 0; float current = 0; LinkedList <string> loadTaskQueue = new LinkedList <string>(); Action <UnityEngine.Object> onloaded = null; onloaded = uobj => { current += 1; EventDispatcher.getInstance().dispatchEvent(EventId.UI_UPDATE_LOADING, current / total); if (current >= total) { EventDispatcher.getInstance().dispatchEvent(EventId.UI_CLOSE_LOADING); callback.Invoke(); return; } var abNode = loadTaskQueue.Last; if (abNode != null) { MgrRes.loadPrefab(abNode.Value, null, onloaded); loadTaskQueue.RemoveLast(); } }; foreach (var item in calculatedLoadResList) { total += 1; loadTaskQueue.AddLast(item.Key); } for (int i = 0; i < MAX_LOAD_TASK; i++) { var abNode = loadTaskQueue.Last; if (abNode != null) { MgrRes.loadPrefab(abNode.Value, null, onloaded); loadTaskQueue.RemoveLast(); } } calculatedLoadResList.Clear(); if (total == 0) { Tools.Log("MgrResLoader process : no calculatedLoadResList"); EventDispatcher.getInstance().dispatchEvent(EventId.UI_CLOSE_LOADING); callback.Invoke(); } }
public virtual void dispose() { bDisposed = true; if (bInited) { UObject.Destroy(gameObject); gameObject = null; transform = null; m_arguments = null; MgrRes.putPrefab(getAssetBundleName(), null); bInited = false; } }
void onLoadPrefab(UObject obj) { if (bDisposed) { MgrRes.putPrefab(getAssetBundleName(), null); return; } gameObject = UObject.Instantiate(obj) as GameObject; transform = gameObject.transform; bInited = true; onCreate(m_arguments); }
public static void setSpriteForContainer(SpriteRenderer render, string spriteName, ResObject container) { if (render == null || container == null || container.isDisposed()) { return; } var objs = spriteName.Split('/'); MgrRes.loadPrefab(objs[0], objs[1], obj => { if (container.isDisposed()) { return; } render.sprite = obj as Sprite; }, true); }
static void preProcess() { calculatedLoadResList.Clear(); foreach (var item in removingResList) { MgrRes.putPrefab(item.Key, null); } foreach (var item in loadingResList) { if (!MgrRes.loadReferencedPrefab(item.Key)) { calculatedLoadResList[item.Key] = true; } } //--清空待卸载列表 removingResList.Clear(); loadingResList.Clear(); }
public ResObject(SObject arguments, Action <ResObject> callback) { m_arguments = arguments; //m_callback = callback; MgrRes.loadPrefab(getAssetBundleName(), null, onLoadPrefab); }