/** * Plays an animation to transition into the current scene. * The game logic will be paused during the animation. * It does not actually change the current scene. * * Usually you want to use `SceneController` instead of this singleton, since it can change the current scene and * does call this singleton internally to play animations. * * @param transitionType which transition animation to play * @param callback function to call when the animation completed */ public void TransitionIntoScene(TransitionType transitionType, TransitionCompletionCallback callback) { // Pause game logic during animation PauseGameLogic.Instance.Pause(); // Remember callback. It will be invoked once the animation completed in the `OnTransitionInCompleted` method. _onTransitionCompleted = callback; // If the transition type is not none, play the transition animation if (transitionType != TransitionType.None) { // If there is a custom animation configured in the settings for the given transition type, use it. // Else, fall back to the default animation. _animator.runtimeAnimatorController = TransitionSettings.Instance.GetAnimatorOverride(transitionType) ?? _originalAnimatorController; // Play the animation _animator.SetTrigger(TransitionIntoSceneTrigger); } // Otherwise, we do not play an animation and the transition is immediately complete else { OnTransitionInCompleted(); } }
private void Update() { if ((_transitionRunning) && (_alpha == _targetAlpha)) { if (TransitionCompletionHandler != null) { TransitionCompletionHandler(); } TransitionCompletionHandler = null; _transitionRunning = false; } }