public void OnTriggerEnter(Collider other) { if (other.CompareTag("Player")) { loadscreen = GameObject.FindGameObjectWithTag("LoadScreen"); popup = GameObject.FindGameObjectWithTag("PopupDiag"); //print("portal collider hit"); levelRestarted = true; islevelrestarted = levelRestarted; if (GameModeScript.GameMode == 1) { // This is commented out TEMPORARILY for VR version- must change cstats.Save to make it work with the new system //cstats.Save(); } if (LevelProgression.MasterLevelMultiplier == 2) { //loadscreen.gameObject.SetActive(true); //popup.gameObject.SetActive(true); } //VRTK_SDKManager.instance.enabled = false; GameObject.Find("RightController").GetComponent <AirsigPickaxe>().enabled = false; SteamVR_LoadLevel.Begin("testscene"); //SceneManager.LoadScene("testscene"); } }
public void OnTriggerEnter(Collider other) { if (other.CompareTag("Player")) { if (nxtIsland) { NextIsland.levelRestarted = true; nxtIsland.islevelrestarted = NextIsland.levelRestarted; } if (GameModeScript.GameMode == 1) { //cstats.Save(); //Temporarily commented out of VR version if (LevelProgression.MasterLevelMultiplier == 4) { GameObject.Find("RightController").GetComponent <AirsigPickaxe>().enabled = false; SteamVR_LoadLevel.Begin("smallcave1"); //SceneManager.LoadScene(2); } if (LevelProgression.MasterLevelMultiplier == 9) { GameObject.Find("RightController").GetComponent <AirsigPickaxe>().enabled = false; SteamVR_LoadLevel.Begin("bosstest"); //SceneManager.LoadScene("bosstest"); } if (LevelProgression.MasterLevelMultiplier == 14) { GameObject.Find("RightController").GetComponent <AirsigPickaxe>().enabled = false; SteamVR_LoadLevel.Begin("smallcave2"); //SceneManager.LoadScene("smallcave2"); } if (LevelProgression.MasterLevelMultiplier == 19) { GameObject.Find("RightController").GetComponent <AirsigPickaxe>().enabled = false; SteamVR_LoadLevel.Begin("bosscave2"); //SceneManager.LoadScene("bosscave2"); } if (LevelProgression.MasterLevelMultiplier == 24) { GameObject.Find("RightController").GetComponent <AirsigPickaxe>().enabled = false; SteamVR_LoadLevel.Begin("smallcave3"); // SceneManager.LoadScene("smallcave3"); } if (LevelProgression.MasterLevelMultiplier == 29) { //SteamVR_LoadLevel.Begin("finaldungeon"); GameObject.Find("RightController").GetComponent <AirsigPickaxe>().enabled = false; //SceneManager.LoadScene("finaldungeon"); StartCoroutine(loadFinal()); } } } }
void OnTriggerEnter(Collider other) { if ((other.gameObject.CompareTag("Throwable")) && (ballReset.starCount >= 2)) { // Create a temporary reference to the current scene. Scene currentScene = SceneManager.GetActiveScene(); // Retrieve the name of this scene. string sceneName = currentScene.name; switch (sceneName) { case ("Scene1"): SteamVR_LoadLevel.Begin("Scene2"); break; case ("Scene2"): SteamVR_LoadLevel.Begin("Scene3"); break; case ("Scene3"): SteamVR_LoadLevel.Begin("Scene4"); break; case ("Scene4"): SteamVR_LoadLevel.Begin("Scene5"); break; default: SteamVR_LoadLevel.Begin("Scene1"); break; } } }
public void ResetGame() { // Restart the current game. string levelName = "Level" + level.ToString(); SteamVR_LoadLevel.Begin(levelName); }
private void OnCollisionEnter(Collision col) { if (col.gameObject.CompareTag("Ground")) { ground.Play(); gameObject.transform.position = ballInstantiate.transform.position; //Destroy(gameObject); //Instantiate(resetBall, ballInstantiate.transform.position, Quaternion.identity); collectible.SetActive(true); collectible1.SetActive(true); } if (col.gameObject.CompareTag("Goal")) { if (CollectibleStar_3_.isTouched && CollectibleStar_3_1.isTouched1) { winState = true; Debug.Log(winState); } if (winState) { Destroy(gameObject); SteamVR_LoadLevel.Begin("Level4"); winState = false; } else { Destroy(gameObject); gameObject.transform.position = ballInstantiate.transform.position; //Instantiate(resetBall, ballInstantiate.transform.position, Quaternion.identity); collectible.SetActive(true); //SteamVR_LoadLevel.Begin("Level3"); winState = false; } } }
/// <summary> /// Method for when scripts starts /// </summary> void Start() { loader = GetComponent <SteamVR_LoadLevel>(); playableDirector = GetComponent <PlayableDirector>(); gameOver = false; StartCoroutine("StartCountDown"); }
private void OnTriggerEnter(Collider other) { var colliderTag = other.gameObject.tag; if (TagUtility.IsButton(colliderTag)) { if (Controller.GetHairTrigger()) { if (TagUtility.IsTutorialButton(colliderTag) && IsGameScene()) { if (MenuManagerBehaviour.Menu) { Destroy(MenuManagerBehaviour.Menu); } transform.parent.GetComponent <MovementChangeBehaviour>().MovementState = State.Tutorial; } else if (TagUtility.IsRestartButton(colliderTag)) { PlayerPrefs.DeleteAll(); SteamVR_LoadLevel.Begin("Game"); } else if (TagUtility.IsQuitButton(colliderTag)) { PlayerPrefs.DeleteAll(); Application.Quit(); } } } }
// Update is called once per frame void Update() { if (GetComponent <DraggableObject>().held) { SteamVR_LoadLevel.Begin(scene); } }
public void LoadPlayground() { // Load player and able bodied avatar (without adaptive tracker). SaveSystem.LoadUserData("DB1942174"); AvatarSystem.LoadPlayer(SaveSystem.ActiveUser.type, AvatarType.AbleBodied); AvatarSystem.LoadAvatar(SaveSystem.ActiveUser, AvatarType.AbleBodied, false); // Change the number for the forearm tracker being used GameObject faTrackerGO = GameObject.FindGameObjectWithTag("ForearmTracker"); SteamVR_TrackedObject steamvrConfig = faTrackerGO.GetComponent <SteamVR_TrackedObject>(); steamvrConfig.index = SteamVR_TrackedObject.EIndex.Device5; // KeepOnLoad(); // Load level. SteamVR_LoadLevel.Begin("DemoPlayground"); /* * KeepOnLoad(); * // Load level. * if (AvatarSystem.AvatarType == AvatarType.Transradial) * { * GameObject prosthesisManagerGO = GameObject.FindGameObjectWithTag("ProsthesisManager"); * FakeEMGBoniHand prosthesisManager = prosthesisManagerGO.GetComponent<FakeEMGBoniHand>(); * prosthesisManager.InitializeProsthesis(); * } * SteamVR_LoadLevel.Begin("FantasyTemplate"); */ //SteamVR_LoadLevel.Begin("PhotoStage"); }
private void OnTriggerEnter(Collider other) { if (other.name.Contains("Body")) { SteamVR_LoadLevel.Begin(scene); } }
// Update is called once per frame void Update() { var R_device = SteamVR_Controller.Input((int)_R_trackedObj.index); var L_device = SteamVR_Controller.Input((int)_L_trackedObj.index); if (Input.GetKeyDown(KeyCode.Return)) { isPCReady = true; PC_Ready_Text.text = "Your Journey Will Begin Shortly..."; StopCoroutine("PCTextFlash"); PC_Ready_Text.color = Color.white; } if (R_device.GetTouch(SteamVR_Controller.ButtonMask.Trigger) && L_device.GetTouch(SteamVR_Controller.ButtonMask.Trigger)) { _GripTimer += Time.deltaTime; } else { _GripTimer = 0f; } if (_GripTimer > 2f) { _isVRReady = true; VR_Ready_Text.text = "Prepare to Defend Heaven..."; StopCoroutine("VRTextFlash"); VR_Ready_Text.color = Color.white; } if (_isVRReady && isPCReady) { //SceneManager.LoadScene ("Level01_VR"); SteamVR_LoadLevel.Begin("Level01_VR"); } }
public void GoToNextLevel() { if (currentLevel + 1 <= levels.Length) { SteamVR_LoadLevel.Begin(levels[currentLevel + 1]); } }
private void Update() { if (device.GetPressDown(SteamVR_Controller.ButtonMask.ApplicationMenu)) { Tutorial.SetActive(!Tutorial.activeSelf); } if (device.GetPress(SteamVR_Controller.ButtonMask.ApplicationMenu)) { holdTime += Time.deltaTime; if (holdTime > 5f) { SteamVR_LoadLevel.Begin("Test"); } } if (device.GetPressUp(SteamVR_Controller.ButtonMask.ApplicationMenu)) { holdTime = 0f; } if (device.GetHairTriggerUp() && currentHeld != null) { currentHeld.GetComponent <VRInteractableObject>().Release(this.gameObject); GetComponent <BoxCollider>().size = regularTriggerSize; currentHeld = null; } }
public void PlayerWon() { //winUI.SetActive(true); currLevel = (currLevel + 1) % 4; SteamVR_LoadLevel.Begin(levelNames[currLevel]); //Debug.Log("Load Next Level"); }
void OnCollisionEnter(Collision other) { if (other.gameObject.CompareTag("Throwable") && AreStarsAndGoalInActive()) { switch (SceneManager.GetActiveScene().name) { case "Start": SteamVR_LoadLevel.Begin("level1"); break; case "Level1": SteamVR_LoadLevel.Begin("level2"); break; case "Level2": SteamVR_LoadLevel.Begin("level3"); break; case "Level3": SteamVR_LoadLevel.Begin("level4"); break; case "Level4": SteamVR_LoadLevel.Begin("WinScreen"); break; default: Debug.Log("StartScreen"); break; } } }
/// <summary> /// OnCollisionEnter is called when this collider/rigidbody has begun /// touching another rigidbody/collider. /// </summary> /// <param name="other">The Collision data associated with this collision.</param> void OnCollisionEnter(Collision other) { if (other.collider.CompareTag("Throwable")) { if (other.gameObject.GetComponent <BallReset>().areAllCollected&& platform.GetComponent <AntiCheat>().onPlatform) { Debug.Log("Yes Goal"); if (scene.name.Equals("Intro")) { SteamVR_LoadLevel.Begin("Scene1"); } else if (scene.name.Equals("Scene1")) { SteamVR_LoadLevel.Begin("Scene2"); } else if (scene.name.Equals("Scene2")) { SteamVR_LoadLevel.Begin("Scene3"); } else if (scene.name.Equals("Scene3")) { SteamVR_LoadLevel.Begin("Scene4"); } else if (scene.name.Equals("Scene4")) { exit = true; } } else { Debug.Log("No Goal"); } } }
private IEnumerator AfterDeadedCoroutine() { // disable gui foreach (Canvas c in fullHacker.GetComponentsInChildren <Canvas>()) { c.enabled = false; } // move player above the map float v = 1.0f; while (fadeOutPercentage < 1.0f) { fadeOutPercentage += Time.deltaTime * 0.5f; // accelerate and move upwards v += 25.0f * Time.deltaTime; fullHacker.transform.position += new Vector3(0, v * Time.deltaTime, 0); yield return(0); } // load end_of_game scene GameData.Instance.successfulHack = false; SteamVR_LoadLevel.Begin("end_of_game", false, 0.1f); }
/// <summary> /// LoadScene /// </summary> /// <param name="targetTrans"></param> /// <param name="player"></param> private void LoadScene(Transform targetTrans, Transform player) //load scene by param's name { switch (targetTrans.name) { case "YongLing": SteamVR_LoadLevel.Begin("YongLing", false, 1, 1, 1, 1, 1); break; case "JinSha": SteamVR_LoadLevel.Begin("JinSha", false, 1, 1, 1, 1, 1); break; case "ZhuYueLian": SteamVR_LoadLevel.Begin("ZhuYueLian", false, 1, 1, 1, 1, 1); break; default: break; } //SteamVR_LoadLevel.Begin(targetTrans.name,false,5,1,1,1,1); }
//The loading scheme for levels public static void LoadNextStage(int currentLevel) { string nextLevel = ""; switch (currentLevel) { case 0: nextLevel = "Level1"; break; case 1: nextLevel = "Level2"; break; case 2: nextLevel = "Level3"; break; case 3: nextLevel = "Level4"; break; } SteamVR_LoadLevel.Begin(nextLevel); }
void Update() { if (Input.GetKeyDown(KeyCode.P)) { SteamVR_LoadLevel.Begin("coffeAmir"); } }
public void GotoMenu() { SoundManager.Instance.StopBGM(); SteamVR_LoadLevel.Begin("menu"); StartCoroutine(WaitForLoading(menuBGM)); }
public void GotoGame() { SoundManager.Instance.StopBGM(); SteamVR_LoadLevel.Begin("game"); StartCoroutine(WaitForLoading(gameBGM)); }
void OnTriggerEnter(Collider col) { if (col.gameObject.CompareTag("Ground")) { ReStart(); } else if (col.gameObject.CompareTag("Star")) { col.gameObject.SetActive(false); starHandler.AddScore(); } else if (col.gameObject.CompareTag("Goal")) { if (starHandler.IsCompleted()) { SteamVR_LoadLevel.Begin(NextScene); } else { ReStart(); } } else if (col.gameObject.CompareTag("StartLevel")) { ReStart(); startInstruction.SetActive(false); } else if (col.gameObject.CompareTag("PlayArea")) { isInPlayArea = true; } }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.F1)) { SteamVR_LoadLevel.Begin("GabrielTest"); } if (Input.GetKeyDown(KeyCode.F2)) { SteamVR_LoadLevel.Begin("Hoops"); } foreach (ControlerController c in controllers) { if (c._joint != null) { if (c._joint.gameObject.name == "Hoop") { SteamVR_LoadLevel.Begin("Hoops"); } else if (c._joint.gameObject.name == "Racket") { SteamVR_LoadLevel.Begin("GabrielTest"); } } } }
// Update is called once per frame void Update() { if (Input.anyKeyDown) { currLevel = (currLevel + 1) % 2; SteamVR_LoadLevel.Begin(levelNames[currLevel]); } }
public void PlayerLose() { PlayerLost = true; LoseUI.SetActive(true); //Load Same Level SteamVR_LoadLevel.Begin("level1"); }
public void NextLevel() { string levelName = SceneManager.GetActiveScene().name; region.MarkLevelComplete(levelName); Save(); SteamVR_LoadLevel.Begin(region.NextLevel(levelName)); }
private void OnCollisionEnter(Collision collision) { if (collision.gameObject.CompareTag("Throwable") && dsg.getCollectedStarts() == dsg.getNbStarsInGame()) { collision.gameObject.GetComponent <Rigidbody>().velocity = Vector3.zero; SteamVR_LoadLevel.Begin(sceneLoading); } }
public void PlayerWin() { PlayerWon = true; WinUI.SetActive(true); //Load Next Level SteamVR_LoadLevel.Begin("level2"); }
private IEnumerator endGame() { // Do something when game ends. yield return(null); SteamVR_LoadLevel.Begin(_sceneToLoad); }
// Corourtine to handle all the steps across loading boundaries. IEnumerator LoadLevel() { // Optionally rotate loading screen transform around the camera into view. // We assume here that the loading screen is already facing toward the origin, // and that the progress bar transform (if any) is a child and will follow along. if (loadingScreen != null && loadingScreenDistance > 0.0f) { // Wait until we have tracking. var hmd = SteamVR_Controller.Input((int)OpenVR.k_unTrackedDeviceIndex_Hmd); while (!hmd.hasTracking) yield return null; var tloading = hmd.transform; tloading.rot = Quaternion.Euler(0.0f, tloading.rot.eulerAngles.y, 0.0f); tloading.pos += tloading.rot * new Vector3(0.0f, 0.0f, loadingScreenDistance); var t = loadingScreenTransform != null ? loadingScreenTransform : transform; t.position = tloading.pos; t.rotation = tloading.rot; } _active = this; SteamVR_Utils.Event.Send("loading", true); // Calculate rate for fading in loading screen and progress bar. if (loadingScreenFadeInTime > 0.0f) { fadeRate = 1.0f / loadingScreenFadeInTime; } else { alpha = 1.0f; } var overlay = OpenVR.Overlay; // Optionally create our loading screen overlay. if (loadingScreen != null && overlay != null) { loadingScreenOverlayHandle = GetOverlayHandle("loadingScreen", loadingScreenTransform != null ? loadingScreenTransform : transform, loadingScreenWidthInMeters); if (loadingScreenOverlayHandle != OpenVR.k_ulOverlayHandleInvalid) { var texture = new Texture_t(); texture.handle = loadingScreen.GetNativeTexturePtr(); texture.eType = SteamVR.instance.graphicsAPI; texture.eColorSpace = EColorSpace.Auto; overlay.SetOverlayTexture(loadingScreenOverlayHandle, ref texture); } } bool fadedForeground = false; // Fade out to compositor SteamVR_Utils.Event.Send("loading_fade_out", fadeOutTime); // Optionally set a skybox to use as a backdrop in the compositor. var compositor = OpenVR.Compositor; if (compositor != null) { if (front != null) { SteamVR_Skybox.SetOverride(front, back, left, right, top, bottom); // Explicitly fade to the compositor since loading will cause us to stop rendering. compositor.FadeGrid(fadeOutTime, true); yield return new WaitForSeconds(fadeOutTime); } else if (backgroundColor != Color.clear) { // Otherwise, use the specified background color. if (showGrid) { // Set compositor background color immediately, and start fading to it. compositor.FadeToColor(0.0f, backgroundColor.r, backgroundColor.g, backgroundColor.b, backgroundColor.a, true); compositor.FadeGrid(fadeOutTime, true); yield return new WaitForSeconds(fadeOutTime); } else { // Fade the foreground color in (which will blend on top of the scene), and then cut to the compositor. compositor.FadeToColor(fadeOutTime, backgroundColor.r, backgroundColor.g, backgroundColor.b, backgroundColor.a, false); yield return new WaitForSeconds(fadeOutTime + 0.1f); compositor.FadeGrid(0.0f, true); fadedForeground = true; } } } // Now that we're fully faded out, we can stop submitting frames to the compositor. SteamVR_Render.pauseRendering = true; // Continue waiting for the overlays to fully fade in before continuing. while (alpha < 1.0f) yield return null; // Keep us from getting destroyed when loading the new level, otherwise this coroutine will get stopped prematurely. transform.parent = null; DontDestroyOnLoad(gameObject); if (loadExternalApp) { Debug.Log("Launching external application..."); var applications = OpenVR.Applications; if (applications == null) { Debug.Log("Failed to get OpenVR.Applications interface!"); } else { var workingDirectory = Directory.GetCurrentDirectory(); var fullPath = Path.Combine( workingDirectory, externalAppPath ); Debug.Log("LaunchingInternalProcess"); Debug.Log("ExternalAppPath = " + externalAppPath); Debug.Log("FullPath = " + fullPath); Debug.Log("ExternalAppArgs = " + externalAppArgs); Debug.Log("WorkingDirectory = " + workingDirectory); var error = applications.LaunchInternalProcess(fullPath, externalAppArgs, workingDirectory); Debug.Log("LaunchInternalProcessError: " + error); #if UNITY_EDITOR UnityEditor.EditorApplication.isPlaying = false; #else Process.GetCurrentProcess().Kill(); #endif } } else { #if !(UNITY_5_2 || UNITY_5_1 || UNITY_5_0) var mode = loadAdditive ? UnityEngine.SceneManagement.LoadSceneMode.Additive : UnityEngine.SceneManagement.LoadSceneMode.Single; if (loadAsync) { Application.backgroundLoadingPriority = ThreadPriority.Low; async = UnityEngine.SceneManagement.SceneManager.LoadSceneAsync(levelName, mode); // Performing this in a while loop instead seems to help smooth things out. //yield return async; while (!async.isDone) { yield return null; } } else { UnityEngine.SceneManagement.SceneManager.LoadScene(levelName, mode); } #else if (loadAsync) { async = loadAdditive ? Application.LoadLevelAdditiveAsync(levelName) : Application.LoadLevelAsync(levelName); // Performing this in a while loop instead seems to help smooth things out. //yield return async; while (!async.isDone) { yield return null; } } else if (loadAdditive) { Application.LoadLevelAdditive(levelName); } else { Application.LoadLevel(levelName); } #endif } yield return null; System.GC.Collect(); yield return null; Shader.WarmupAllShaders(); // Optionally wait a short period of time after loading everything back in, but before we start rendering again // in order to give everything a change to settle down to avoid any hitching at the start of the new level. yield return new WaitForSeconds(postLoadSettleTime); SteamVR_Render.pauseRendering = false; // Fade out loading screen. if (loadingScreenFadeOutTime > 0.0f) { fadeRate = -1.0f / loadingScreenFadeOutTime; } else { alpha = 0.0f; } // Fade out to compositor SteamVR_Utils.Event.Send("loading_fade_in", fadeInTime); if (compositor != null) { // Fade out foreground color if necessary. if (fadedForeground) { compositor.FadeGrid(0.0f, false); compositor.FadeToColor(fadeInTime, 0.0f, 0.0f, 0.0f, 0.0f, false); yield return new WaitForSeconds(fadeInTime); } else { // Fade scene back in, and reset skybox once no longer visible. compositor.FadeGrid(fadeInTime, false); yield return new WaitForSeconds(fadeInTime); if (front != null) { SteamVR_Skybox.ClearOverride(); } } } // Finally, stick around long enough for our overlays to fully fade out. while (alpha > 0.0f) yield return null; if (overlay != null) { if (progressBarOverlayHandle != OpenVR.k_ulOverlayHandleInvalid) overlay.HideOverlay(progressBarOverlayHandle); if (loadingScreenOverlayHandle != OpenVR.k_ulOverlayHandleInvalid) overlay.HideOverlay(loadingScreenOverlayHandle); } Destroy(gameObject); _active = null; SteamVR_Utils.Event.Send("loading", false); }
// Corourtine to handle all the steps across loading boundaries. IEnumerator LoadLevel() { var vr = SteamVR.instance; // Optionally rotate loading screen transform around the camera into view. // We assume here that the loading screen is already facing toward the origin, // and that the progress bar transform (if any) is a child and will follow along. if (loadingScreen != null && loadingScreenDistance > 0.0f) { // Wait until we have tracking. var hmd = SteamVR_Controller.Input((int)OpenVR.k_unTrackedDeviceIndex_Hmd); while (!hmd.hasTracking) yield return null; var tloading = hmd.transform; tloading.rot = Quaternion.Euler(0.0f, tloading.rot.eulerAngles.y, 0.0f); tloading.pos += tloading.rot * new Vector3(0.0f, 0.0f, loadingScreenDistance); var t = loadingScreenTransform != null ? loadingScreenTransform : transform; t.position = tloading.pos; t.rotation = tloading.rot; } _active = this; SteamVR_Utils.Event.Send("loading", true); // Calculate rate for fading in loading screen and progress bar. if (loadingScreenFadeInTime > 0.0f) { fadeRate = 1.0f / loadingScreenFadeInTime; } else { alpha = 1.0f; } // Optionally create our loading screen overlay. if (loadingScreen != null) { loadingScreenOverlayHandle = GetOverlayHandle("loadingScreen", loadingScreenTransform != null ? loadingScreenTransform : transform, loadingScreenWidthInMeters); if (loadingScreenOverlayHandle != OpenVR.k_ulOverlayHandleInvalid) { vr.overlay.SetHighQualityOverlay(loadingScreenOverlayHandle); vr.overlay.SetOverlayFlag(loadingScreenOverlayHandle, VROverlayFlags.Curved, false); vr.overlay.SetOverlayFlag(loadingScreenOverlayHandle, VROverlayFlags.RGSS4X, true); var texture = new Texture_t(); texture.handle = loadingScreen.GetNativeTexturePtr(); texture.eType = vr.graphicsAPI; texture.eColorSpace = EColorSpace.Auto; vr.overlay.SetOverlayTexture(loadingScreenOverlayHandle, ref texture); } } bool fadedForeground = false; // Optionally set a skybox to use as a backdrop in the compositor. if (front != null) { SteamVR_Skybox.SetOverride(front, back, left, right, top, bottom); // Explicitly fade to the compositor since loading will cause us to stop rendering. vr.compositor.FadeGrid(fadeOutTime, true); yield return new WaitForSeconds(fadeOutTime); } else if (backgroundColor != Color.clear) { // Otherwise, use the specified background color. if (showGrid) { // Set compositor background color immediately, and start fading to it. vr.compositor.FadeToColor(0.0f, backgroundColor.r, backgroundColor.g, backgroundColor.b, backgroundColor.a, true); vr.compositor.FadeGrid(fadeOutTime, true); yield return new WaitForSeconds(fadeOutTime); } else { // Fade the foreground color in (which will blend on top of the scene), and then cut to the compositor. vr.compositor.FadeToColor(fadeOutTime, backgroundColor.r, backgroundColor.g, backgroundColor.b, backgroundColor.a, false); yield return new WaitForSeconds(fadeOutTime + 0.1f); vr.compositor.FadeGrid(0.0f, true); fadedForeground = true; } } // Now that we're fully faded out, we can stop submitting frames to the compositor. SteamVR_Render.pauseRendering = true; // Continue waiting for the overlays to fully fade in before continuing. while (alpha < 1.0f) yield return null; // Keep us from getting destroyed when loading the new level, otherwise this coroutine will get stopped prematurely. transform.parent = null; DontDestroyOnLoad(gameObject); // Loading asynchronously so we can update the progress bar above. async = loadAdditive ? Application.LoadLevelAdditiveAsync(levelName) : Application.LoadLevelAsync(levelName); yield return async; System.GC.Collect(); // Optionally wait a short period of time after loading everything back in, but before we start rendering again // in order to give everything a change to settle down to avoid any hitching at the start of the new level. yield return new WaitForSeconds(postLoadSettleTime); SteamVR_Render.pauseRendering = false; // Fade out loading screen. if (loadingScreenFadeOutTime > 0.0f) { fadeRate = -1.0f / loadingScreenFadeOutTime; } else { alpha = 0.0f; } // Fade out foreground color if necessary. if (fadedForeground) { vr.compositor.FadeGrid(0.0f, false); vr.compositor.FadeToColor(fadeInTime, 0.0f, 0.0f, 0.0f, 0.0f, false); yield return new WaitForSeconds(fadeInTime); } else { // Fade scene back in, and reset skybox once no longer visible. vr.compositor.FadeGrid(fadeInTime, false); yield return new WaitForSeconds(fadeInTime); if (front != null) { SteamVR_Skybox.ClearOverride(); } } // Finally, stick around long enough for our overlays to fully fade out. while (alpha > 0.0f) yield return null; Destroy(gameObject); _active = null; SteamVR_Utils.Event.Send("loading", false); }