public ResourceScene CoLoadScene(string path, bool isAddition) { if (!isAddition) { Dictionary <string, ResourceScene> tmpScens = new Dictionary <string, ResourceScene>(m_resScenes); foreach (string item in tmpScens.Keys) { if (item == path) { continue; } this.UnloadScene(item); } } ResourceState resState = new ResourceState(this); ulong reqId = this.GenReqId(); resState.req = ResourceRequest.CreateAsyncRequest(m_resLoader, path, this.ResLoadSceneEndCall, reqId); ResourceScene resScene = new ResourceScene(resState); resScene.TryLoadAsset(); m_resScenes.Add(resScene.sceneName, resScene); return(resScene); }
public void AsyncLoadScene(string path, bool isAddition, System.Action <ResourceScene.LoadResult, string> cb) { if (!isAddition) { Dictionary <string, ResourceScene> tmpScens = new Dictionary <string, ResourceScene>(m_resScenes); foreach (string item in tmpScens.Keys) { if (item == path) { continue; } this.UnloadScene(item); } } ResourceScene resScene = this.GetResScene(path); if (null != resScene) { resScene.isAddition = isAddition; // 不存在Fail和Released的情况,因为函数逻辑会马上把这些情况的resScene移出m_resScenes // 不存在Inited的情况,因为所有的resScene一创建马上就TryLoadAssset了 if (resScene.isLoading) { if (null != resScene.cb) { resScene.cb(ResourceScene.LoadResult.Cancel, resScene.sceneName); resScene.SetCb(cb); } } else if (resScene.isLoaded) { resScene.ReloadScene(cb); } } else { ResourceState resState = new ResourceState(this); ulong reqId = this.GenReqId(); resState.req = ResourceRequest.CreateAsyncRequest(m_resLoader, path, this.ResLoadSceneEndCall, reqId); resScene = new ResourceScene(resState); resScene.SetCb(cb); m_resScenes.Add(resScene.sceneName, resScene); resScene.TryLoadAsset(); } }