private IEnumerator Start() { yield return(new WaitForSceneLoadFinish()); Scene s = USceneManager.GetActiveScene(); foreach (var g in s.GetRootGameObjects()) { if (g.name.Contains("_Transition") || g.layer == (int)GlobalEnums.PhysLayers.TRANSITION_GATES || g.GetComponent <TransitionPoint>() != null) { if (SetupMode) { g.gameObject.AddComponent <ShowColliders>(); } Logger.LogDebug($"Skip gate object:{g.name}"); continue; } if (g.GetComponent <CustomDecoration>() != null) { continue; } Destroy(g.gameObject); } UnVisableBehaviour.AttackReact.Create(gameObject); }
private static IEnumerator LoadInternal(LoadContext context) { if (context == null) { yield break; } var scene = UnitySceneManager.GetSceneByName(context.NextScene.Name); if (!scene.isLoaded) { yield return(UnitySceneManager.LoadSceneAsync(context.NextScene.Name, LoadSceneMode.Additive)); } UnitySceneManager.SetActiveScene(UnitySceneManager.GetSceneByName(context.NextScene.Name)); var sceneContext = FindSceneContext(context.NextScene.Name); if (sceneContext == null) { yield break; } yield return(new WaitUntil(() => sceneContext.Initialized)); var sceneSettings = sceneContext.Container.TryResolve <SceneSettings>(); if (sceneSettings != null) { sceneSettings.Subs.ForEach(x => context.AddAdditiveScene(x)); } context.NextScene.Lifecycles = sceneContext.Container.ResolveAll <ISceneLifecycle>(); }
IEnumerator LoadSceneAsync(int sceneName) { float alpha = splashScreen.alpha; // fadeIn splashScreen for (float t = 0.0f; t < 1.0f; t += Time.deltaTime) { splashScreen.alpha = t; yield return(null); } splashScreen.alpha = 1.0f; AsyncOperation loading = UnitySceneManger.LoadSceneAsync(sceneName); while (!loading.isDone) { yield return(null); } // fadeOut splashScreen for (float t = 1.0f; t > 0.0f; t -= Time.deltaTime) { splashScreen.alpha = t; yield return(null); } splashScreen.alpha = 0.0f; }
public static IEnumerator LoadSceneAsyncCo(string sceneName, float minDuration) { USM.sceneLoaded += OrientNewScene; var asyncOp = USM.LoadSceneAsync(sceneName); if (minDuration > 0) { asyncOp.allowSceneActivation = false; yield return(new WaitForSecondsRealtime(minDuration)); for (float t = 0; t < minDuration; t += Time.unscaledDeltaTime) { Shader.SetGlobalFloat("_NormalisedProgress", t / minDuration); yield return(null); } Shader.SetGlobalFloat("_NormalisedProgress", 1); asyncOp.allowSceneActivation = true; } while (!asyncOp.isDone) { yield return(null); } }
public static void LoadSceneByName(String name, bool force = false) { Scene scene = SCM.GetSceneByName(name); if (force) { if (!scene.isLoaded) { SCM.LoadScene(name); } else { SCM.LoadScene(scene.name); } } else if (!scene.isLoaded) { SCM.LoadSceneAsync(name); } else { SCM.LoadSceneAsync(scene.name); } }
public static void LoadSceneById(int id, bool force = false) { if (id >= GetSceneCount()) { throw new Exception("Scene Index outisde of Range"); } int index = 1 + id; Scene scene = SCM.GetSceneByBuildIndex(index); if (force) { if (!scene.isLoaded) { SCM.LoadScene(index); } else { SCM.LoadScene(scene.name); } } else if (!scene.isLoaded) { SCM.LoadSceneAsync(index); } else { SCM.LoadSceneAsync(scene.name); } }
private IEnumerator AnimateUnloadAdditiveScene(SceneAnimationEventsManager animEventsManager, Action onUnloaded = null) { if (additiveScenes.Count > 0) { if (animEventsManager == null) { animEventsManager = FindObjectsOfType <SceneAnimationEventsManager>() .FirstOrDefault(m => m.gameObject.scene == UnitySceneManager.GetSceneByBuildIndex((int)additiveScenes.Peek())); } // Found if (animEventsManager != null) { animEventsManager.FadeOut(); yield return(new WaitUntil(() => animEventsManager.FadedOut)); } var scene = additiveScenes.Pop(); UnloadScene((int)scene); onUnloaded?.Invoke(); } this.RemoveCoroutine(nameof(AnimateUnloadAdditiveScene)); }
private static IEnumerator LoadSubsInternal(LoadContext context, LoadContext prev) { yield return(context.AdditiveScenes .Where(x => { if (prev == null) { return true; } var cache = prev.AdditiveScenes.FirstOrDefault(y => x.Name == y.Name); if (cache == null) { return true; } else { x.Lifecycles = cache.Lifecycles; } return false; }) .Select(additiveScene => UnitySceneManager.LoadSceneAsync(additiveScene.Name, LoadSceneMode.Additive) .AsObservable() .Select(_ => FindSceneContext(additiveScene.Name)) .SelectMany(x => new WaitUntil(() => x.Initialized) .ToObservable() .Select(_ => x)) .Do(x => additiveScene.Lifecycles = x.Container.ResolveAll <ISceneLifecycle>().Where(y => !context.NextScene.Lifecycles.Any(z => y == z))) .FirstOrDefault()) .WhenAll() .StartAsCoroutine()); Resources.UnloadUnusedAssets(); GC.Collect(); }
/// <summary> /// Unload a scene loaded via AddScene /// </summary> public void UnloadAddedScene(string sceneName) { for (int i = 0; i < mScenesAdded.Count; i++) { if (mScenesAdded[i].name == sceneName) { mScenesAdded.RemoveAt(i); UnitySceneManager.UnloadScene(sceneName); return; } } //check the queue if (mScenesToAdd.Contains(sceneName)) { //reconstruct the queue excluding the sceneName var newSceneQueue = new Queue <string>(); while (mScenesToAdd.Count > 0) { var s = mScenesToAdd.Dequeue(); if (s != sceneName) { newSceneQueue.Enqueue(s); } } mScenesToAdd = newSceneQueue; } }
IEnumerator LoadSceneGame(int weight) { Scene scene = SceneManager.GetSceneByName("Game"); if (scene.isLoaded) { _asyncOperation = SceneManager.UnloadSceneAsync(scene); while (!_asyncOperation.isDone) { yield return(0); } } _asyncOperation = SceneManager.LoadSceneAsync("Game", LoadSceneMode.Additive); _asyncOperation.allowSceneActivation = false; yield return(0); float progress = 0; while (!_asyncOperation.isDone) { progress = _asyncOperation.progress < 0.9f ? _asyncOperation.progress : 1; yield return(progress * weight); if (progress >= 0.9f) { _asyncOperation.allowSceneActivation = true; } } }
IEnumerator DoAddScene() { while (mScenesToAdd.Count > 0) { //wait for scene removes to finish while (mSceneRemoveRout != null) { yield return(null); } var sceneName = mScenesToAdd.Dequeue(); var sync = UnitySceneManager.LoadSceneAsync(sceneName, LoadSceneMode.Additive); while (!sync.isDone) { yield return(null); } var sceneAdded = UnitySceneManager.GetSceneByName(sceneName); mScenesAdded.Add(sceneAdded); if (sceneAddedCallback != null) { sceneAddedCallback(sceneAdded); } } mSceneAddRout = null; }
/// <summary> /// 游戏框架组件初始化。 /// </summary> protected override void Awake() { base.Awake(); m_SceneManager = GameFrameworkEntry.GetModule <ISceneManager>(); if (m_SceneManager == null) { Log.Fatal("Scene manager is invalid."); return; } m_SceneManager.LoadSceneSuccess += OnLoadSceneSuccess; m_SceneManager.LoadSceneFailure += OnLoadSceneFailure; m_SceneManager.LoadSceneUpdate += OnLoadSceneUpdate; m_SceneManager.LoadSceneDependencyAsset += OnLoadSceneDependencyAsset; m_SceneManager.UnloadSceneSuccess += OnUnloadSceneSuccess; m_SceneManager.UnloadSceneFailure += OnUnloadSceneFailure; m_GameFrameworkScene = SceneManager.GetSceneAt(GameEntry.GameFrameworkSceneId); if (!m_GameFrameworkScene.IsValid()) { Log.Fatal("Game Framework scene is invalid."); return; } }
public void SetCurrentScene(SceneName sceneName) { var scene = UnitySceneManager.GetSceneByName(sceneName.ToString()); UnitySceneManager.SetActiveScene(scene); loadedSceneNames.Add(sceneName.ToString()); }
public static void PatchScene(string sceneName) { Scene scene = USceneManager.GetSceneByName(sceneName); switch (scene.name) { case "Crossroads_11_alt": case "Crossroads_ShamanTemple": case "Fungus1_28": new[] { "Blocker", "Blocker 1", "Blocker 2" } .Select(str => scene.FindGameObject(str)) .Where(obj => obj != null) .ToList() .ForEach(PatchBlocker); break; case "Crossroads_38": PatchGrubFather(scene.FindGameObject("Grub King").LocateMyFSM("King Control")); break; case "Ruins1_05b": PatchLemm(scene.FindGameObject("Relic Dealer")); break; } }
protected override void OnInstanceInit() { mCurScene = UnitySceneManager.GetActiveScene(); mFirstSceneLoaded = new SceneAssetPath(mCurScene); if (!_rootScene.isValid) { _rootScene = mFirstSceneLoaded; } //mIsFullscreen = Screen.fullScreen; mPauseCounter = 0; mTransitions = new List <ITransition>(); if (stackEnable) { mSceneStack = new Stack <string>(stackCapacity); } mScenesAdded = new List <Scene>(); mScenesToAdd = new Queue <string>(); mScenesToRemove = new Queue <Scene>(); }
void Update() { if (SceneManager.GetActiveScene().name == "Level Select") { Time.timeScale = 1; } if (SceneManager.GetActiveScene().name != PrevScene) { IEnumerator Fade = FadeOutMusic(); // GetComponent<AudioSource>().volume = 0; if (SceneManager.GetActiveScene().name == "Level Select" || SceneManager.GetActiveScene().name == "End Game") { Time.timeScale = 1f; if (!CurrentlyFading) { StartCoroutine(Fade); } } else { StopCoroutine(Fade); } } // if (SceneManager.GetActiveScene().name != "Level Select" && GetComponent<AudioSource>().isPlaying) // GetComponent<AudioSource>().volume = 1f; PrevScene = SceneManager.GetActiveScene().name; }
IEnumerator LoodSceneByNameRoutine(string level, float duraction) { onSceneLeave?.Invoke(duraction); yield return(new WaitForSeconds(duraction)); InternalSceneManager.LoadScene(level); routine = null; }
/// <summary> /// 异步加载场景 /// </summary> /// <param name="sceneName"></param> public Task <AsyncOperation> LoadSceneAsync(string assetBundleName, string sceneName, LoadSceneMode mode = LoadSceneMode.Additive) { TaskCompletionSource <AsyncOperation> task = new TaskCompletionSource <AsyncOperation>(); task.SetResult(UnitySceneManager.LoadSceneAsync(sceneName, mode)); //Debug.Log("szfsdfsd"); return(task.Task); // return UnitySceneManager.LoadSceneAsync(sceneName, mode); }
/// <summary> /// Unloads all added scenes loaded via AddScene /// </summary> public void UnloadAddedScenes() { for (int i = 0; i < mScenesAdded.Count; i++) { UnitySceneManager.UnloadScene(mScenesAdded[i]); } ClearAddSceneData(); }
/// <summary> /// Loads scene only if not already loaded /// </summary> /// <param name="scene"></param> public void LoadAdditiveScene(Scene scene) { if (!additiveScenes.Contains(scene)) { UnitySceneManager.LoadSceneAsync((int)scene, LoadSceneMode.Additive); additiveScenes.Push(scene); } }
public static int obj_hash(long L) { UnityEngine.SceneManagement.SceneManager obj = FCGetObj.GetObj <UnityEngine.SceneManagement.SceneManager>(L); if (obj != null) { return(obj.GetHashCode()); } return(0); }
public void Load(string sceneName, System.Action onSceneLoaded) { Debug.LogFormat("[SceneManager] Load(sceneName = {0}, onSceneLoaded = {1})", sceneName, onSceneLoaded); SManager.LoadScene(EmptyScene, LoadSceneMode.Single); StartCoroutine(WaitUntilSceneLoaded(sceneName, onSceneLoaded)); SManager.LoadScene(sceneName, LoadSceneMode.Single); }
private IEnumerator Start() { var scene = UnitySceneManager.GetActiveScene(); var context = FindSceneContext(scene.name); yield return(new WaitUntil(() => context.Initialized)); Next(scene.name, null, TransMode.None); }
IEnumerator LoadSceneAsync(string sceneName) { AsyncOperation asyncLoad = Manager.LoadSceneAsync(sceneName); // Wait until the asynchronous scene fully loads while (!asyncLoad.isDone) { yield return(null); } }
/// <summary> /// Tries to load the next scene. /// <para>Return if the next scene is valid</para> /// </summary> public static bool TryLoadNextScene(LoadSceneMode loadSceneMode) { if (!SceneExists(NextSceneIndex)) { return(false); } SM.LoadScene(NextSceneIndex, loadSceneMode); return(true); }
public void BackToMenu() { Time.timeScale = 1; if (Manager.GetActiveScene().name == "Menu") { return; } NetworkHandler.Instance.Disconnect(); LoadScene("Menu"); }
public async UniTask RemoveAsync(Scenes scene) { var sceneData = list.Get(scene); await UniSceneManager.UnloadSceneAsync(sceneData.mainScene); if (sceneData.backgroundScene != null) { await UniSceneManager.UnloadSceneAsync(sceneData.backgroundScene); } }
/// <summary> Loads the next scene asynchronously </summary> public static bool TryLoadNextSceneAsync(LoadSceneMode loadSceneMode, out AsyncOperation asyncOperation) { if (!SceneExists(NextSceneIndex)) { asyncOperation = null; return(false); } asyncOperation = SM.LoadSceneAsync(NextSceneIndex, loadSceneMode); return(true); }
/// <summary> /// Tries to get the given index's scene /// </summary> public static bool TryGetSceneAt(int index, out Scene scene) { if (!SceneExists(index)) { scene = default; return(false); } scene = SM.GetSceneAt(index); return(true); }
/// <summary> /// Loads a scene /// </summary> /// <param name="scene"></param> /// <param name="loadMode"></param> /// <returns></returns> public static AsyncOperation LoadScene(TCScene scene, LoadSceneMode loadMode = LoadSceneMode.Single) { PreparingSceneLoadEvent?.Invoke(scene); Debug.Log($"The scene `{scene.scene}` was requested to be loaded."); AsyncOperation sceneLoad = SceneManager.LoadSceneAsync(scene.scene, loadMode); StartSceneLoadEvent?.Invoke(sceneLoad); return(sceneLoad); }
static public int constructor(IntPtr l) { try { UnityEngine.SceneManagement.SceneManager o; o=new UnityEngine.SceneManagement.SceneManager(); pushValue(l,true); pushValue(l,o); return 2; } catch(Exception e) { return error(l,e); } }
static int _CreateUnityEngine_SceneManagement_SceneManager(IntPtr L) { int count = LuaDLL.lua_gettop(L); if (count == 0) { UnityEngine.SceneManagement.SceneManager obj = new UnityEngine.SceneManagement.SceneManager(); LuaScriptMgr.PushObject(L, obj); return 1; } else { LuaDLL.luaL_error(L, "invalid arguments to method: UnityEngine.SceneManagement.SceneManager.New"); } return 0; }