protected IEnumerator Transition(string newSceneName, bool resetInputValues, SceneTransitionDestination.DestinationTag destinationTag, TransitionPoint.TransitionType transitionType = TransitionPoint.TransitionType.DifferentZone) { m_Transitioning = true; PersistentDataManager.SaveAllData(); if (m_PlayerInput == null) { m_PlayerInput = FindObjectOfType <PlayerInput>(); } m_PlayerInput.ReleaseControl(resetInputValues); yield return(StartCoroutine(ScreenFader.FadeSceneOut(ScreenFader.FadeType.Loading))); PersistentDataManager.ClearPersisters(); yield return(SceneManager.LoadSceneAsync(newSceneName)); m_PlayerInput = FindObjectOfType <PlayerInput>(); m_PlayerInput.ReleaseControl(resetInputValues); PersistentDataManager.LoadAllData(); var entrance = GetDestination(destinationTag); SetEnteringGameObjectLocation(entrance); SetupNewScene(transitionType, entrance); if (entrance != null) { entrance.OnReachDestination.Invoke(); } yield return(StartCoroutine(ScreenFader.FadeSceneIn())); m_PlayerInput.GainControl(); m_Transitioning = false; }
protected void SetupNewScene(TransitionPoint.TransitionType transitionType, SceneTransitionDestination entrance) { if (entrance == null) { Debug.LogWarning("Restart information has not been set."); return; } if (transitionType == TransitionPoint.TransitionType.DifferentZone) { SetZoneStart(entrance); } }
//Corutina de Transicion de escena lo incialisa el metodo TransitionToScene y RestartZone arriba, protected IEnumerator Transition(string newSceneName, bool resetInputValues, SceneTransitionDestination.DestinationTag destinationTag, TransitionPoint.TransitionType transitionType = TransitionPoint.TransitionType.DifferentZone) { m_Transitioning = true; PersistentDataManager.SaveAllData();//salve todos los datos //si el input esta vacio encuentrelo if (m_PlayerInput == null) { m_PlayerInput = FindObjectOfType <PlayerInput>(); } m_PlayerInput.ReleaseControl(resetInputValues); //Pierde el control del input liberelo reseteando los valores yield return(StartCoroutine(ScreenFader.FadeSceneOut(ScreenFader.FadeType.Loading))); //Llame la corutina de FadeSceneOut de tipo Loading PersistentDataManager.ClearPersisters(); yield return(SceneManager.LoadSceneAsync(newSceneName)); //carge la nueva escena asincronicamente m_PlayerInput = FindObjectOfType <PlayerInput>(); //encuentre el input m_PlayerInput.ReleaseControl(resetInputValues); //libere y resetee valores PersistentDataManager.LoadAllData(); //carge todos los datos SceneTransitionDestination entrance = GetDestination(destinationTag); //en una variable de tipo scirpt SceneTransitio...obtenga el destino llamando el metodo protegido mas abajo SetEnteringGameObjectLocation(entrance); //le paso como variable lo recogido en el metodo anterior, este nuevo metodo es llamado mas abajo SetupNewScene(transitionType, entrance); //configure la nueva escena, metodo mas abajo if (entrance != null) //en caso de que siga vacio { entrance.OnReachDestination.Invoke(); //entrance es una instancia de SceneTransitionDest... que luego llama que llama al campo OnReach.invoke que son un evento de Unity } //Es como un llamado para asegurarse que si encunter el destino, en el inpector se especifica, ademas de llamar al script CharacterStateSetter que permite configurar al personaje una vez entre(posicion, animador, etc). yield return(StartCoroutine(ScreenFader.FadeSceneIn())); //fadeIn m_PlayerInput.GainControl(); //obtenga control nuevamente m_Transitioning = false; }
private IEnumerator Transition(string newSceneName, CellTransitionDestination.DestinationTag destinationTag, TransitionPoint.TransitionType transitionType = TransitionPoint.TransitionType.DifferentZone) { m_Transitioning = true; yield return(StartCoroutine(ScreenFader.FadeSceneOut(ScreenFader.FadeType.Black))); yield return(SceneManager.LoadSceneAsync(newSceneName)); cellController = FindObjectOfType <CellController>(); screenManager = FindObjectOfType <ScreenManager>(); parallaxScroller = FindObjectOfType <ParallaxScroller>(); var publisher = FindObjectOfType <Publisher>(); publisher.GainOrReleaseControl(false); cellController.GetRootCell(out rootCell); cellController.SetCell(rootCell, destinationTag); publisher.SetObservers(false, true, cellController.LastEnteringDestination.locations); screenManager.autoCameraSetup.SetMainConfinerBound(rootCell.confinerCollider); yield return(StartCoroutine(ScreenFader.FadeSceneIn())); publisher.GainOrReleaseControl(true); m_Transitioning = false; }
protected IEnumerator Transition(string newSceneName, bool resetInputValues, TransitionDestination.DestinationTag destinationTag, TransitionPoint.TransitionType transitionType = TransitionPoint.TransitionType.DifferentZone) { m_Transitioning = true; yield return(SceneManager.LoadSceneAsync(newSceneName)); TransitionDestination entrance = GetDestination(destinationTag); SetEnteringGameObjectLocation(entrance); SetupNewScene(transitionType, entrance); if (entrance != null) { entrance.onReachDestination.Invoke(); } m_Transitioning = false; }