static IEnumerator _TransitionScene(string scene_name, float duration_sec, SceneTransitionCallback callback, AnimationCurve ease_curve = null)
    {
        // Transition out of the current scene.
        float ending_time = Time.time + duration_sec * 0.5f;

        while (Time.time < ending_time)
        {
            float progress = Mathf.Clamp01(1.0f - (ending_time - Time.time) / (duration_sec * 0.5f));
            if (ease_curve != null)
            {
                progress = ease_curve.Evaluate(progress);
            }
            singleton.effect.SetProgress(progress);

            yield return(null);
        }

        // Load new scene.
        singleton._current_state = SceneTransitionState.LOADING_SCENE;
        loading_operation        = SceneManager.LoadSceneAsync(scene_name);
        callback(singleton._current_state, scene_name);
        float loading_start_time           = Time.time;
        float minimum_loading_duration_sec = 0.5f;

        while (!loading_operation.isDone || Time.time - loading_start_time < minimum_loading_duration_sec)
        {
            singleton.effect.SetProgress(1.0f);
            yield return(null);
        }

        // Transition into the current scene.
        singleton._current_state = SceneTransitionState.ENTERING_SCENE;
        callback(singleton._current_state, scene_name);

        ending_time = Time.time + duration_sec * 0.5f;
        while (Time.time < ending_time)
        {
            float progress = Mathf.Clamp01((ending_time - Time.time) / (duration_sec * 0.5f));
            if (ease_curve != null)
            {
                progress = ease_curve.Evaluate(progress);
            }
            singleton.effect.SetProgress(progress);

            yield return(null);
        }

        singleton.effect.SetProgress(0.0f);
        singleton._current_state = SceneTransitionState.NOT_TRANSITIONING;
        callback(singleton._current_state, scene_name);
    }
    static public void TransitionToScene(string scene, float duration, FadeColor fadeColor, SceneTransitionCallback callback = null)
    {
        _toScene    = scene;
        _toCallback = callback;

        if (fadeColor == FadeColor.Black)
        {
            ScreenFader.FadeToBlack(duration, OnFadeOutComplete);
        }
        else if (fadeColor == FadeColor.White)
        {
            ScreenFader.FadeToWhite(duration, OnFadeOutComplete);
        }
    }
    /* Public Usage Interface */
    public static bool RequestSceneTransition(string scene_name, float duration_sec, SceneTransitionCallback callback, Texture fade_shape, AnimationCurve ease_curve = null, float max_fade_image_size_factor = 4.0f)
    {
        Debug.Log("Requested Transition");
        if (singleton._current_state != SceneTransitionState.NOT_TRANSITIONING)
        {
            return(false);
        }

        singleton.effect.SetFadeShape(fade_shape);
        singleton.effect.SetMaximumSizeFactor(max_fade_image_size_factor);

        singleton._current_state = SceneTransitionState.LEAVING_SCENE;
        callback(singleton._current_state, SceneManager.GetActiveScene().name);

        singleton.StartCoroutine(_TransitionScene(scene_name, duration_sec, callback, ease_curve));
        return(true);
    }
 static public void TransitionToScene(string scene, float duration, FadeColor fadeColor, AudioSourceExtended[] audio, SceneTransitionCallback callback = null)
 {
     TransitionToScene(scene, duration, fadeColor, callback);
     AudioUtils.FadeOutAudio(audio, duration);
 }
 static public void TransitionToScene(string scene, float duration, SceneTransitionCallback callback = null)
 {
     TransitionToScene(scene, duration, FadeColor.Black, callback);
 }
 static public void TransitionToScene(string scene, AudioSourceExtended[] audio, SceneTransitionCallback callback = null)
 {
     TransitionToScene(scene, DEFAULT_DURATION, FadeColor.Black, callback);
     AudioUtils.FadeOutAudio(audio, DEFAULT_DURATION);
 }
 static public void TransitionToScene(string scene, FadeColor fadeColor, SceneTransitionCallback callback = null)
 {
     TransitionToScene(scene, DEFAULT_DURATION, fadeColor, callback);
 }