public void Initialize(AdditiveSceneComponent component) { if (config != null) { return; } config = Resources.Load <SceneManagerConfig>("SceneManagerConfig"); if (config == null) { throw new Exception($"{this} Cant load scene manager config from Resources/SceneManagerConfig"); } string parentSceneName = component.Config.SceneParent.Name; SceneConfig scene = config.Scenes.FirstOrDefault(x => x.Name.ToLowerInvariant() == parentSceneName.ToLowerInvariant()); if (scene == null) { throw new Exception($"{this} no configuration for the current scene: {parentSceneName}"); } if (scene.Async) { SceneManagement.LoadSceneAsync(scene.Name, UnityEngine.SceneManagement.LoadSceneMode.Single); } else { SceneManagement.LoadScene(scene.Name); } }
public void CallBtn(int idBtn) { //GameSingleton.Instance.GetPlayer().Save(); switch (idBtn) { case 0: GameSingleton.Instance.sceneManager.LoadScene("Menu"); break; case 1: Player player = GameSingleton.Instance.GetPlayer(); Player.Gamemode playerGamemode = player.gamemode; if (playerGamemode == Player.Gamemode.LEVEL) { player.gold = player.goldStartLevel; player.storyModeInventory = player.inventoryBackup; } Shop.Instance.ClearShop(); GameSingleton.Instance.uiManager.inventoryUi.UpdateGold(); SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex); break; } gameObject.SetActive(false); }
public void LoadScene(CocoSceneID sceneId) { if (!LoadSceneModule(sceneId)) { return; } SceneManager.LoadScene(m_CurrSceneModule.Data.sceneName); }
/// <summary>example: LoadScene(SceneManager.INTRO)</summary> public static bool LoadScene(string sceneName, float fadeOutTime = 0.4f, float fadeInTime = 1.0f) { var at = AppTransition.instance; if (at != null && !at.isTransitioning) { at.AnimateTransition(fadeOutTime, fadeInTime, () => USM.LoadScene(sceneName), null); return(true); } return(false); }
public void ChangeActiveScene(int buildIndexOffset) { if (Manager.sceneCountInBuildSettings < 1) { return; } int newSceneBuildIndex = Manager.GetActiveScene().buildIndex; newSceneBuildIndex += buildIndexOffset; newSceneBuildIndex += Manager.sceneCountInBuildSettings << 10; newSceneBuildIndex %= Manager.sceneCountInBuildSettings; newSceneBuildIndex = Mathf.Clamp(newSceneBuildIndex, 0, Manager.sceneCountInBuildSettings - 1); Manager.LoadScene(newSceneBuildIndex); UpdateSceneNameText(); }
private static IEnumerator LoadStateCoro() { USceneManager.LoadScene("Room_Sly_Storeroom"); yield return(new WaitUntil(() => USceneManager.GetActiveScene().name == "Room_Sly_Storeroom")); GameManager.instance.sceneData = SceneData.instance = JsonUtility.FromJson <SceneData>(JsonUtility.ToJson(_savedSd)); GameManager.instance.ResetSemiPersistentItems(); yield return(null); HeroController.instance.gameObject.transform.position = _savePos; PlayerData.instance = GameManager.instance.playerData = HeroController.instance.playerData = JsonUtility.FromJson <PlayerData>(JsonUtility.ToJson(_savedPd)); On.HeroController.EnterScene += Ok; USceneManager.LoadScene(_saveScene); yield return(null); HeroController.instance.gameObject.transform.position = _savePos; yield return(null); yield return(null); cameraLockArea.SetValue(GameManager.instance.cameraCtrl, _lockArea); GameManager.instance.cameraCtrl.LockToArea(_lockArea as CameraLockArea); cameraGameplayScene.SetValue(GameManager.instance.cameraCtrl, true); yield return(new WaitUntil(() => USceneManager.GetActiveScene().name == _saveScene)); HeroController.instance.gameObject.transform.position = _savePos; HeroController.instance.TakeMP(1); HeroController.instance.AddMPChargeSpa(1); HeroController.instance.TakeHealth(1); HeroController.instance.AddHealth(1); GameCameras.instance.hudCanvas.gameObject.SetActive(true); On.HeroController.EnterScene -= Ok; }
public void LoadScene(string sceneName) { Player player = GameSingleton.Instance.GetPlayer(); SoundManager soundManager = GameSingleton.Instance.soundManager; PoolManager.PoolManager.Instance().ReleaseAll(); switch (sceneName) { case "Menu": //soundManager.StopPlaying("Level theme"); soundManager.StopPlayingAllMusics(); soundManager.Play("Menu"); if (player.gamemode != Player.Gamemode.LEVEL) { player.arcadeModeInventory.Clear(); Shop.Instance.ClearShop(); player.arcadeGold = 150; player.currentLevelArcade = 0; } else { player.storyModeInventory = player.inventoryBackup; player.gold = player.goldStartLevel; //player.storyModeInventory.Clear(); } player.gamemode = Player.Gamemode.NONE; UnitySceneManager.LoadScene(_storedScenesIds[sceneName]); break; case "StoryMode": if (player.gamemode == Player.Gamemode.LEVEL) // button restart { player.storyModeInventory = player.inventoryBackup; player.gold = player.goldStartLevel; } Shop.Instance.ClearShop(); player.gamemode = Player.Gamemode.LEVEL; soundManager.StopPlayingAllMusics(); //soundManager.StopPlaying("Menu"); soundManager.Play("Level theme"); UnitySceneManager.LoadScene(_storedScenesIds[sceneName]); break; case "freeMode": string token = player.token; if (string.IsNullOrEmpty(token) || token.Length < 8) { Popups.instance.Popup(Traducer.Translate("Not connected!"), Color.red); } else { GameSingleton.Instance.tokenManager.CheckToken(token, "scene.load.freeMode"); Shop.Instance.ClearShop(); player.currentLevelArcade = 0; player.arcadeModeInventory.Clear(); player.arcadeGold = 150; player.gamemode = Player.Gamemode.ARCADE; soundManager.StopPlayingAllMusics(); soundManager.Play("Level theme"); UnitySceneManager.LoadScene(_storedScenesIds[sceneName]); } break; case "loadLvl": GameSingleton.Instance.GetPlayer().gamemode = Player.Gamemode.PERSONNALIZED; player.arcadeModeInventory.Clear(); player.arcadeGold = 150; UnitySceneManager.LoadScene(_storedScenesIds[sceneName]); break; case "creator": UnitySceneManager.LoadScene(_storedScenesIds[sceneName]); break; } }
// private void Awake() => DontDestroyOnLoad(this); public void ChangeScene(int _sceneID) => SceneManager.LoadScene(_sceneID);
public void LoadGameLevel() { USceneManager.LoadScene(_levelScene.SceneName); }
private void LoginSuccess() { SceneManager.LoadScene("TokenRegistration"); }
public void SplashFinishedSceneChange() { SceneManager.LoadScene(nextScene); }
public SceneManager() { var subscriber = new Subscriber(); var currentSceneName = ""; GameObject loading = null; // Scene Loaded subscriber.Subscribe(EventTopics.SceneAwake, () => currentSceneName = SceneManagement.GetActiveScene().name); // Scene Change subscriber.Subscribe <string>(EventTopics.SceneChange, (triggerName) => { SceneConfig scene = config.Scenes.FirstOrDefault(x => String.Equals(x.Name, currentSceneName, StringComparison.InvariantCultureIgnoreCase)); if (scene == null) { throw new Exception($"{this} no configuration for the current scene: {currentSceneName}"); } SceneNext next = scene.LinkTo.FirstOrDefault(x => String.Equals(x.TriggerName, triggerName, StringComparison.InvariantCultureIgnoreCase)); if (next == null) { throw new Exception($"{this} no configuration for this trigger scene: {currentSceneName}, trigger: {triggerName}"); } SceneConfig nextConfig = config.Scenes.FirstOrDefault(x => String.Equals(x.Name, next.SceneName.Name, StringComparison.InvariantCultureIgnoreCase)); if (nextConfig == null) { throw new Exception($"{this} no configuration for this scene: {next.SceneName.Name}"); } if (nextConfig.Async) { SceneManagement.LoadSceneAsync(next.SceneName.Name, UnityEngine.SceneManagement.LoadSceneMode.Single); } else { SceneManagement.LoadScene(next.SceneName.Name); } }); // Scene Loading subscriber.Subscribe(EventTopics.SceneLoading, () => { loading = Object.Instantiate(config.LoadingPrefab); loading.GetComponent <CanvasGroup>().alpha = 1; }); subscriber.Subscribe(EventTopics.SceneLoaded, () => { loading.GetComponent <CanvasGroup>().alpha = 0; Object.Destroy(loading); loading = null; }); // Additive Scene subscriber.Subscribe <string>(EventTopics.SceneLoadAdditive, (name) => { SceneConfig scene = config.Scenes.FirstOrDefault(x => x.Name.ToLowerInvariant() == currentSceneName.ToLowerInvariant()); if (scene == null) { throw new Exception($"{this} no configuration for the current scene: {currentSceneName}"); } SceneAdditiveConfig additive = scene.Additives.FirstOrDefault(x => x.Name.ToLowerInvariant() == name.ToLowerInvariant()); if (additive == null) { throw new Exception($"{this} no configuration for this additive scene: {currentSceneName}, additive: {name}"); } currentScene.StartCoroutine(LoadAdditiveScene(additive.Name)); }); subscriber.Subscribe <string>(EventTopics.SceneLoadAdditiveAwake, (name) => { // if the additive scene is opened directly if (currentScene == null) { return; } SceneConfig scene = config.Scenes.FirstOrDefault(x => x.Name.ToLowerInvariant() == currentSceneName.ToLowerInvariant()); if (scene == null) { throw new Exception($"{this} no configuration for the current scene: {currentSceneName}"); } SceneAdditiveConfig additive = scene.Additives.FirstOrDefault(x => x.Name.ToLowerInvariant() == name.ToLowerInvariant()); if (additive == null) { throw new Exception($"{this} no configuration for this additive scene: {currentSceneName}, additive: {name}"); } if (additive.ActiveOnLoad) { SceneManagement.SetActiveScene(SceneManagement.GetSceneByName(additive.Name)); } }); }
public void UnloadCurrScene() { SceneManager.LoadScene(EMPTY_SCENE_NAME); UnloadCurrSceneModule(); }
private IEnumerator RunLoad <T>(string scenePath, object bundle, string transition = TransitionFactory.FadeTransition) where T : IScene { if (IsLoading) { Debug.LogWarning("Scenes is loading, do not load again"); yield break; } isLoading = true; var lst = curScene; if (lst != null) { //VRProfiler.StartWatch(string.Format("[LoadingScene] Scene: {0} UnLoad ", lst.Name)); Events.DispathMsg(Event_OnUnload, lst.Name); lst.Unload(); //VRProfiler.StopWatch(); } //VRProfiler.StartWatch("[LoadingScene] Transition In "); curScene = null; if (null == mask) { mask = TransitionFactory.CreateTransition(transition); } mask.DontDestroyOnLoad(); SetRaycast(false); yield return(mask.TransitIn(TransitionLength)); //VRProfiler.StopWatch(); //VRProfiler.StartWatch("[LoadingScene] Switch To Scene: Loading "); //销毁场景物件 if (lst != null) { Destroy(lst.UnityObject); } //切换至空场景 UnitySceneMgr.LoadScene(VRScene.Loading); //VRProfiler.StopWatch(); //VRProfiler.StartWatch("[LoadingScene] Unload Unused Assets "); //资源回收 yield return(1); yield return(Resources.UnloadUnusedAssets()); GC.Collect(); //VRProfiler.StopWatch(); //VRProfiler.StartWatch(string.Format("[LoadingScene] Switch to Scene:{0} ",scenePath)); //切换下一场景 yield return(UnitySceneMgr.LoadSceneAsync(scenePath)); SetRaycast(true); //场景handler curScene = GetMissingSceneObj <T>(); curScene.Name = scenePath; curScene.gameObject.name = curScene.GetType().Name; //配置场景相关内容 curScene.name = "[scene] " + curScene.Name; // VRProfiler.StopWatch(); //场景加载完成 isLoading = false; //VRProfiler.StartWatch(string.Format("[LoadingScene] Scene: {0} Preload ", curScene.Name)); curScene.Preload(bundle); //VRProfiler.StopWatch(); //等待场景 //VRProfiler.StartWatch(string.Format("[LoadingScene] Scene: {0} Wait ", curScene.Name)); yield return(curScene.Wait()); // VRProfiler.StopWatch(); //VRProfiler.StartWatch(string.Format("[LoadingScene] Scene: {0} Loaded ", curScene.Name)); curScene.Loaded(); Events.DispathMsg(Event_OnLoaded, curScene.Name); //VRProfiler.StopWatch(); //VRProfiler.StartWatch("[LoadingScene] Transition Out "); //黑幕打开 if (null != mask) { yield return(mask.TransitOut(TransitionLength)); mask.DestroySelf(); mask = null; } //VRProfiler.StopWatch(); yield return(1); //加载完成 curScene.Opened(); }
public static void LoadSceneInstant(string sceneName) { USM.LoadScene(sceneName); }
private static IEnumerator LoadStateCoro() { if (_savedPd == null || string.IsNullOrEmpty(_saveScene)) { yield break; } GameManager.instance.entryGateName = "dreamGate"; GameManager.instance.startedOnThisScene = true; USceneManager.LoadScene("Room_Sly_Storeroom"); yield return(new WaitUntil(() => USceneManager.GetActiveScene().name == "Room_Sly_Storeroom")); GameManager.instance.sceneData = SceneData.instance = JsonUtility.FromJson <SceneData>(JsonUtility.ToJson(_savedSd)); GameManager.instance.ResetSemiPersistentItems(); yield return(null); PlayerData.instance = GameManager.instance.playerData = HeroController.instance.playerData = JsonUtility.FromJson <PlayerData>(JsonUtility.ToJson(_savedPd)); GameManager.instance.BeginSceneTransition ( new GameManager.SceneLoadInfo { SceneName = _saveScene, HeroLeaveDirection = GatePosition.unknown, EntryGateName = "dreamGate", EntryDelay = 0f, WaitForSceneTransitionCameraFade = false, Visualization = 0, AlwaysUnloadUnusedAssets = true } ); ReflectionHelper.SetAttr(GameManager.instance.cameraCtrl, "isGameplayScene", true); GameManager.instance.cameraCtrl.PositionToHero(false); if (_lockArea != null) { GameManager.instance.cameraCtrl.LockToArea(_lockArea as CameraLockArea); } yield return(new WaitUntil(() => USceneManager.GetActiveScene().name == _saveScene)); GameManager.instance.cameraCtrl.FadeSceneIn(); HeroController.instance.TakeMP(1); HeroController.instance.AddMPChargeSpa(1); HeroController.instance.TakeHealth(1); HeroController.instance.AddHealth(1); HeroController.instance.geoCounter.geoTextMesh.text = _savedPd.geo.ToString(); GameCameras.instance.hudCanvas.gameObject.SetActive(true); cameraGameplayScene.SetValue(GameManager.instance.cameraCtrl, true); yield return(null); HeroController.instance.gameObject.transform.position = _savePos; HeroController.instance.transitionState = HeroTransitionState.WAITING_TO_TRANSITION; typeof(HeroController) .GetMethod("FinishedEnteringScene", BindingFlags.NonPublic | BindingFlags.Instance)? .Invoke(HeroController.instance, new object[] { true, false }); }
public void OnSwitchScene() { SceneManager.LoadScene(sceneName); }