static public LoadLevelAsync ( string assetBundleName, string levelName, bool isAdditive ) : AssetBundleLoadOperation | ||
assetBundleName | string | |
levelName | string | |
isAdditive | bool | |
return | AssetBundleLoadOperation |
IEnumerator LoadChapterSceneAsync(int chapter) { // This is simply to get the elapsed time for this phase of AssetLoading float startTime = Time.realtimeSinceStartup; // Load level from assetBundle var sceneAssetBundle = "chapter" + chapter; var levelName = "Chapter" + chapter; // Simulate the preload for a minimim of x seconds yield return(new WaitForSeconds(3)); AssetBundleLoadOperation request = AssetBundleManager.LoadLevelAsync(sceneAssetBundle, levelName, false); if (request == null) { yield break; } yield return(StartCoroutine(request)); // Calculate and display the elapsed time. float elapsedTime = Time.realtimeSinceStartup - startTime; Debug.Log("Finished loading Chapter scene " + levelName + " in: " + elapsedTime + " seconds"); // Notify store when scene has loaded Unidux.Store.Dispatch(Game.ActionCreator.SceneLoaded(levelName)); }
private IEnumerator ChangeLoginInternal(Action sceneLoadComplete = null) { GameEventManager.RaiseEvent(GameEventTypes.ExitScene); string sceneBundleName = string.Format("scenes/scene_login.bundle"); Resources.UnloadUnusedAssets(); m_operation = AssetBundleManager.LoadLevelAsync(sceneBundleName, "login", false); while (!m_operation.IsDone()) { m_progress = m_operation.Progress; yield return(null); } m_operation.UnloadAssetBundle(); AssetBundleManager.Clear(); GameEventManager.RaiseEvent(GameEventTypes.EnterScene, 0); if (sceneLoadComplete != null) { sceneLoadComplete(); } }
private IEnumerator StartLoadLevel(string assetBundleName, string levelName) { if (!string.IsNullOrEmpty(this.m_currentLevel)) { AssetBundleManager.UnloadAssetBundle(this.m_currentLevel, true); } yield return(new WaitForEndOfFrame()); #if DEBUG_ASSETBUNDLE Debug.Log("---------"); #endif SceneManager.LoadScene("empty"); yield return(new WaitForEndOfFrame()); #if DEBUG_ASSETBUNDLE Debug.Log("--- load level asy ---"); #endif AssetBundleLoadOperation level = AssetBundleManager.LoadLevelAsync(assetBundleName, levelName); yield return(level); this.m_currentLevel = assetBundleName; if (this.mLoadLevelCallback != null) { this.mLoadLevelCallback(); this.mLoadLevelCallback = null; } }
static public int LoadLevelAsync_s(IntPtr l) { try { #if DEBUG var method = System.Reflection.MethodBase.GetCurrentMethod(); string methodName = GetMethodName(method); #if UNITY_5_5_OR_NEWER UnityEngine.Profiling.Profiler.BeginSample(methodName); #else Profiler.BeginSample(methodName); #endif #endif System.String a1; checkType(l, 1, out a1); System.String a2; checkType(l, 2, out a2); var ret = AssetBundleManager.LoadLevelAsync(a1, a2); pushValue(l, true); pushValue(l, ret); return(2); } catch (Exception e) { return(error(l, e)); } #if DEBUG finally { #if UNITY_5_5_OR_NEWER UnityEngine.Profiling.Profiler.EndSample(); #else Profiler.EndSample(); #endif } #endif }
private IEnumerator InitializeLevelAsync(string sceneBundleName, string sceneName, UnityAction SceneLoadDoneCallback, float timedur) { IsChecking = true; StartCoroutine(CheckingDownload()); yield return(new WaitForSeconds(timedur)); // // Load level from assetBundle. AssetBundleLoadOperation request = AssetBundleManager.LoadLevelAsync(sceneBundleName, sceneName, true); if (request == null) { StartCoroutine(InitializeLevelAsync(sceneBundleName, sceneName, SceneLoadDoneCallback, timedur)); yield break; } yield return(StartCoroutine(request)); // IsChecking = false; if (SceneLoadDoneCallback != null) { SceneLoadDoneCallback(); } isLoading = false; PopupAndLoadingScript.instance.HideLoading(); }
protected IEnumerator InitializeLevelAsync(string levelName, bool isAdditive) { // This is simply to get the elapsed time for this phase of AssetLoading. float startTime = Time.realtimeSinceStartup; // Load level from assetBundle. AssetBundleLoadOperation request = AssetBundleManager.LoadLevelAsync(sceneAssetBundle, levelName, isAdditive); if (request == null) { yield break; } yield return(StartCoroutine(request)); // Trigger callbacks once the scene has loaded //OnFinished(true); finishedLoading = true; if (NetworkManager.singleton.isNetworkActive && NetworkServer.connections.Count > 0) { NetworkServer.SpawnObjects(); } // Calculate and display the elapsed time. float elapsedTime = Time.realtimeSinceStartup - startTime; Debug.Log("Finished loading scene " + levelName + " in " + elapsedTime + " seconds"); }
IEnumerator <YieldInstruction> InitializeAndThenLoadSceneIntoLevel(string assetBundleName, string sceneName) { #if DLK_AssetBundleIntegrationEnabled initialized = true; if (variantPossibilities != null && variantPossibilities.Length > 0) { SetVariant(activeVariant); } else { variantPossibilities = null; activeVariant = null; } AssetBundleManager.logMode = logMode == AssetBundleManagerLogMode.All ? AssetBundleManager.LogMode.All : AssetBundleManager.LogMode.JustErrors; if (streamingType == StreamingType.SimulationModeOrLocalAssetServer) { AssetBundleManager.SetDevelopmentAssetBundleServer(); } else if (streamingType == StreamingType.StreamingAssetsFolder) { AssetBundleManager.SetSourceAssetBundleURL("file:///" + Application.streamingAssetsPath + "/"); } else { AssetBundleManager.SetSourceAssetBundleURL(serverURL); } // Initialize AssetBundleManifest which loads the AssetBundleManifest object. var initializeRequest = AssetBundleManager.Initialize(); if (initializeRequest != null) { while (initializeRequest.MoveNext()) { yield return(null); } } AssetBundleLoadOperation levelLoadRequest = AssetBundleManager.LoadLevelAsync(assetBundleName, sceneName, true); if (levelLoadRequest != null) { while (levelLoadRequest.MoveNext()) { yield return(null);//request.Current just returns null, so we can do that instead } AssetBundleManager.UnloadAssetBundle(assetBundleName); } else { Debug.Log("Could not load level " + assetBundleName + " Asset Bundle."); yield break; } #else throw new NotImplementedException("You must enable Asset Bundle Integration to utilize the Asset Bundle Loader."); #endif }
/// <summary> /// 场景 /// </summary> /// <returns></returns> private IEnumerator Worker_Scene() { if (AssetBundleManager.isCanLoadLevel(m_SceneName)) { double loadsceneFileTime = DateTime.Now.Ticks; m_AsyncOperation = AssetBundleManager.LoadLevelAsync(m_SceneName); while (!m_AsyncOperation.isDone) { yield return(endofframe); } yield return(endofframe); ImageSetting.ApplySceneImageSettingWhenAfterLoadingScene(); InvokeSceneActiveChangeEvent(m_SceneName); //将摄像机的位置移到目标点.不需要移动了,现在优化了加载速度,可以了 // Initialize.mainCam.transform.SetPosition(m_vecBornPos); AdvanceProgress(30); loadsceneFileTime = DateTime.Now.Ticks - loadsceneFileTime; loadsceneFileTime *= 0.0000001f; Debug.Log("场景文件加载完成,耗时:" + loadsceneFileTime); currentLoadingTime += loadsceneFileTime; yield return(new WaitForSeconds(1.0f)); currentLoadingTime++; } else { Trace.Error("scene:" + m_SceneName + " can not be loaded due to that is not in level setting"); } }
IEnumerator EnterGame() { yield return(new WaitForSeconds(2.0f)); if (AssetBundleManager.isCanLoadLevel(PerformanceCheckManager.LoginSceneName)) { AssetBundleManager.LoadLevelAsync(PerformanceCheckManager.LoginSceneName); } }
public static ITask LoadScene(string path, LoadSceneMode mode = LoadSceneMode.Single) { if (!path.Contains(Resource.BundleSeperator.ToString())) { return(AsyncManager.AddOperation(SceneManager.LoadSceneAsync(path, mode))); } string[] parts = path.Split(Resource.BundleSeperator); return(AssetBundleManager.LoadLevelAsync(parts[0], parts[1], mode)); }
public IEnumerator LoadScene(string assetBundleName, string scenseName, bool isAddtive) { AssetBundleManager.UnloadAssetBundle(assetBundleName); AssetBundleLoadOperation request = AssetBundleManager.LoadLevelAsync(assetBundleName, scenseName, true); if (request == null) { yield break; } yield return(context.StartCoroutine(request)); }
public IEnumerator LoadLevelAsync(string bundleName, string sceneName, bool isAdditive) { AssetBundleLoadOperation async = AssetBundleManager.LoadLevelAsync(bundleName, sceneName, isAdditive); while (!async.IsDone()) { yield return(null); } yield break; }
public IEnumerator LoadLevelAsync(string name) { Debug.Log("start load: " + name); AssetBundleLoadOperation request = AssetBundleManager.LoadLevelAsync("ab_scenes_" + name, name, false); if (request == null) { yield break; } yield return(StartCoroutine(request)); }
private IEnumerator ChangeSceneInternal(int sceneCfgID, Action sceneLoadComplete = null) { GameEventManager.RaiseEvent(GameEventTypes.ExitScene); GameEventManager.EnableEventFiring = false; string assetName = ConfigManager.Get <SceneCfgLoader>().GetSceneAssetName(sceneCfgID); string sceneBundleName = string.Format("scenes/scene_{0}.bundle", assetName.ToLower()); m_operation = AssetBundleManager.LoadLevelAsync(sceneBundleName, assetName, false); m_progress = 0f; while (!m_operation.IsDone()) { m_progress = m_operation.Progress; yield return(null); } m_operation.UnloadAssetBundle(); AssetBundleManager.Clear(); GameEventManager.EnableEventFiring = true; AssetBundleManager.UnloadAssetBundle(string.Format("scenes/{0}.bundle", assetName)); var trunkMgrGo = GameObject.FindGameObjectWithTag("SceneTrunkMgr"); if (trunkMgrGo != null) { trunkMgr = trunkMgrGo.GetComponent <SceneTrunkMgr>(); } // 等待主角周围地块加载完毕 if (trunkMgr != null) { while (trunkMgr.HasLoadingTrunk()) { yield return(null); } } GameEventManager.RaiseEvent(GameEventTypes.EnterScene, sceneCfgID); if (sceneLoadComplete != null) { sceneLoadComplete(); } }
public IEnumerator LoadScene(string levelName) { Debug.Log("### start LoadScene >> " + levelName); AssetBundleLoadOperation request = AssetBundleManager.LoadLevelAsync(ASSET_BUNDLE_SCENES, levelName, true); if (request == null) { yield break; } yield return(StartCoroutine(request)); Debug.Log("finish LoadScene >> " + levelName); }
/* * summary * 씬 로드시 로드되어있는 씬일 경우 ActiveScene으로 설정 * 씬 로드가 안되어있을 경우 씬의 전환을 이룸. * summary */ public IEnumerator LoadScene(string sceneName, bool isLoading = true, bool isImediately = true, bool isAdditive = true) { Debug.LogFormat("LoadScene {0}", sceneName); // Scene in sceneNameList if (_sceneNameList.Contains(sceneName)) { foreach (var scene in _sceneNameList) { if (scene == sceneName) { Debug.Log("ActiveScene Change : " + sceneName); SceneManager.SetActiveScene(SceneManager.GetSceneByName(sceneName)); yield break; } } } else { yield return(new WaitForSeconds(0.1f)); //LoadLevelAsync함수를 통해 에셋을 로드대기 시키고 AssetBundleLoadOperation생성후 반환 AssetBundleLoadOperation request = AssetBundleManager.LoadLevelAsync(AssetManager.Instance._assetBundleKeys[ASSET_TYPE.GAME_SCENES], sceneName, isAdditive); if (request == null) { yield break; } if (isLoading) { LoadingBarScript loading = GameObject.Find("Script").GetComponent <LoadingBarScript>(); StartCoroutine(loading.SetLoadingProgressBar(request)); } while (!request.IsDone()) { yield return(null); } if (isImediately) { SceneManager.SetActiveScene(SceneManager.GetSceneByName(sceneName)); Debug.Log("씬 활성화 : " + SceneManager.GetActiveScene().name); } _sceneNameList.Add(sceneName); } }
protected IEnumerator InitializeLevelAsync(string sceneAssetBundle, string levelName, bool isAdditive) { float startTime = Time.realtimeSinceStartup; AssetBundleLoadOperation request = AssetBundleManager.LoadLevelAsync(sceneAssetBundle, levelName, isAdditive); if (request == null) { yield break; } yield return(StartCoroutine(request)); float elapsedTime = Time.realtimeSinceStartup - startTime; Debug.Log("Finished loading scene " + levelName + " in " + elapsedTime + " seconds"); }
protected IEnumerator LoadLevel(string assetBundleName, string levelName, bool isAdditive) { Debug.Log("Start to load scene " + levelName + " at frame " + Time.frameCount); // Load level from assetBundle. AssetBundleLoadOperation request = AssetBundleManager.LoadLevelAsync(assetBundleName, levelName, isAdditive); if (request == null) { yield break; } yield return(StartCoroutine(request)); // This log will only be output when loading level additively. Debug.Log("Finish loading scene " + levelName + " at frame " + Time.frameCount); }
protected IEnumerator LoadLevel(string assetBundleName, string levelName, Action fn) { // Debug.Log("Start to load scene " + levelName + " at frame " + Time.frameCount); // Load level from assetBundle. AssetBundleLoadBaseOperation request = AssetBundleManager.LoadLevelAsync(assetBundleName, levelName, false); if (request != null) { yield return(StartCoroutine(request)); } if (fn != null) { fn(); } }
protected IEnumerator InitializeLevelAsync(AssetsTableScriptableObject.AssetEntry assetEntry, bool isAdditive = false) { //float startTime = Time.realtimeSinceStartup; AssetBundleLoadOperation request = AssetBundleManager.LoadLevelAsync(assetEntry.AssetBundleName, assetEntry.AssetName, isAdditive); if (request == null) { yield break; } yield return(StartCoroutine(request)); //Calculate and display the elapsed time. //float elapsedTime = Time.realtimeSinceStartup - startTime; //Debug.Log("Finished loading scene " + levelName + " in " + elapsedTime + " seconds"); }
protected IEnumerator InitializeLevelAsync(string levelName, bool isAdditive) { // This is simply to get the elapsed time for this phase of AssetLoading. float startTime = Time.realtimeSinceStartup; // Load level from assetBundle. AssetBundleLoadOperation request = AssetBundleManager.LoadLevelAsync(assetBundleSceneName, levelName, isAdditive); if (request == null) { yield break; } yield return(StartCoroutine(request)); // Calculate and display the elapsed time. float elapsedTime = Time.realtimeSinceStartup - startTime; Debug.Log("Finished loading scene " + levelName + " in " + elapsedTime + " seconds"); }
public IEnumerator LoadLevelAsync(string levelName, bool isAdditive) { Debug.Log("LoadLevelAsync:" + levelName); if (_ResFromBundle) { string sceneAssetBundle = "Scene/" + levelName + ".common"; AssetBundleLoadOperation request = AssetBundleManager.LoadLevelAsync(sceneAssetBundle.ToLower(), levelName, isAdditive); if (request == null) { yield break; } yield return(StartCoroutine(request)); } else { yield return(SceneManager.LoadSceneAsync(levelName, isAdditive ? LoadSceneMode.Additive : LoadSceneMode.Single)); } }
private IEnumerator LoadTerrainTrunk(int index) { RuntimeSceneTrunkDataEntry trunkData = runtimeData[index]; if (trunkData == null) { loadedTrunks.Add(index); yield break; } if (string.IsNullOrEmpty(trunkData.data.trunkBundlePath) || string.IsNullOrEmpty(trunkData.data.trunkName)) { loadedTrunks.Add(index); yield break; } loadingTrunks.Add(index); var asyncOp = AssetBundleManager.LoadLevelAsync(trunkData.data.trunkBundlePath, trunkData.data.trunkName, true); yield return(asyncOp); // Loading request has been cancelled if (loadingTrunks.IndexOf(index) == -1) { yield break; } GameObject terrainObj = GameObject.Find(string.Format("/Terrain_{0}_{1}", trunkData.data.x, trunkData.data.z)); runtimeData[index].terrainObj = terrainObj; runtimeData[index].terrain = terrainObj.GetComponent <Terrain>(); loadingTrunks.Remove(index); loadedTrunks.Add(index); RefreshLodRelation(); AssetBundleManager.UnloadAssetBundle(trunkData.data.trunkBundlePath); yield break; }
public IEnumerator LoadSceneAsync(string sceneName, string sceneAssetBundle, bool isAdditive = false, Action <float> progressListener = null) { AssetBundleLoadOperation request = AssetBundleManager.LoadLevelAsync(sceneAssetBundle, sceneName, isAdditive); if (request == null) { yield break; } if (progressListener == null) { // 方案一 yield return(StartCoroutine(request)); } else { // 方案二 TODO 可能有BUG { int maxTry = 0; while (request.Process() < 0.9f) { if (request.Process() < 0.001f && maxTry++ > 100) { Debug.LogError("网络无法获得资源:" + sceneAssetBundle + " " + sceneName); } // TODO 进度条处理 Debug.Log("加载:" + request.Process() * 100 + "/100"); yield return(new WaitForEndOfFrame()); } while (!request.IsDone()) { Debug.Log("加载:" + request.Process() * 100 + "/100"); yield return(new WaitForEndOfFrame()); } Debug.Log("加载:100/100"); } } }
public string LoadSceneAsync(string assetBundle, string sceneName, bool isAdditive, bool allowSceneActivation = true, OnLoadComplete callback = null) { if (string.IsNullOrEmpty(assetBundle)) { return(string.Empty); } assetBundle = assetBundle.ToLower(); if (IsInLoading(sceneName)) { RegistCallback(sceneName, callback); return(sceneName); } RegistCallback(sceneName, callback); m_LoadSceneOpration = AssetBundleManager.LoadLevelAsync(assetBundle, sceneName, isAdditive, allowSceneActivation); LoadingSceneProgress = 0; return(sceneName); }
public IEnumerator ChangeSceneAsyncByAssetBundle(string assetbundleName, string sceneName, ILoadingProgress loadingBar, bool forceLoad = true) { LoggerManager.Instance.Warn("-----sync load " + assetbundleName); selfLoadingProgress = 0f; sceneName = GetSceneName(sceneName); // Previous action maybe stop, Wait for previous loading finished while (Application.isLoadingLevel) { LoggerManager.Instance.Warn("Waiting for previous loading finished"); yield return(null); } if (CheckSceneChanging(sceneName, forceLoad) == false) { yield break; } // Notice listener scene will change for (int i = 0; i < sceneManagerListeners.Count; ++i) { sceneManagerListeners[i].OnSceneWillChange(this, CurrentSceneName, sceneName); } yield return(null); yield return(null); yield return(StartCoroutine(AssetBundleManager.LoadLevelAsync(assetbundleName, sceneName, false, loadingBar))); string oldSceneName = CurrentSceneName; OnChangeSceneCompleted(oldSceneName); AssetBundleManager.UnloadAssetBundle(assetbundleName); yield return(null); yield return(null); }
IEnumerator <YieldInstruction> LoadSceneIntoLevel(string assetBundleName, string sceneName) { #if DLK_AssetBundleIntegrationEnabled AssetBundleLoadOperation request = AssetBundleManager.LoadLevelAsync(assetBundleName, sceneName, true); if (request != null) { while (request.MoveNext()) { yield return(null);//request.Current just returns null, so we can do that instead } AssetBundleManager.UnloadAssetBundle(assetBundleName); } else { Debug.Log("Could not load level " + assetBundleName + " Asset Bundle."); yield break; } #else throw new NotImplementedException("You must enable Asset Bundle Integration to utilize the Asset Bundle Loader."); #endif }
public void Load() { if (!this.assetBundleName.IsNullOrEmpty()) { if (!this.isAsync) { AssetBundleManager.LoadLevel(this.assetBundleName, this.levelName, this.isAdd, this.manifestFileName); } else { this.assetBundleOperation = AssetBundleManager.LoadLevelAsync(this.assetBundleName, this.levelName, this.isAdd, this.manifestFileName) as AssetBundleLoadLevelOperation; } } else if (!this.isAsync) { SceneManager.LoadScene(this.levelName, !this.isAdd ? (LoadSceneMode)0 : (LoadSceneMode)1); } else { this.operation = SceneManager.LoadSceneAsync(this.levelName, !this.isAdd ? (LoadSceneMode)0 : (LoadSceneMode)1); } }
protected IEnumerator InitializeLevelAsync(string levelName, bool isAdditive) { // This is simply to get the elapsed time for this phase of AssetLoading. float startTime = Time.realtimeSinceStartup; // Load level from assetBundle. AssetBundleLoadOperation request = AssetBundleManager.LoadLevelAsync(sceneAssetBundle, levelName, isAdditive); if (request == null) { yield break; } // 方案一 // yield return StartCoroutine(request); // 方案二 { while (request.Process() < 0.9f) { // TODO 进度条处理 Debug.Log("加载:" + request.Process() * 100 + "/100"); yield return(new WaitForEndOfFrame()); } while (!request.IsDone()) { Debug.Log("加载:" + request.Process() * 100 + "/100"); yield return(new WaitForEndOfFrame()); } Debug.Log("加载:100/100"); } // Calculate and display the elapsed time. float elapsedTime = Time.realtimeSinceStartup - startTime; Debug.Log("Finished loading scene " + levelName + " in " + elapsedTime + " seconds"); }
public AssetBundleLoadOperation LoadSceneAsync( string sceneName, LoadSceneMode loadMode, Action <DiContainer> extraBindings, LoadSceneRelationship containerMode) { if (!_assetBundleInitializer.IsInitialized) { return(new PendingLoadOperation( _assetBundleInitializer, this, sceneName, loadMode, extraBindings, containerMode)); } PrepareForLoadScene(loadMode, extraBindings, containerMode); return(AssetBundleManager.LoadLevelAsync( _assetBundleName, sceneName, loadMode == LoadSceneMode.Additive)); }