/// <summary>
        /// Do the switching bgm algorithm.
        /// </summary>
        private void DoSwitchBGM()
        {
            if (!mSwitchingBGM)
            {
                return;
            }

            /* Once if fade out we load next sound buffer. */

            if (!mDoneFadingOut)
            {
                // check if the sound is fade out.
                if (!mJCSFadeSound.IsReachTargetVolume())
                {
                    return;
                }

                // get the background music audio source.
                AudioSource bgmAudioSource = GetBGMAudioSource();

                // set the audio source.
                mJCSFadeSound.SetAudioSource(bgmAudioSource);

                // set the bgm and play it
                bgmAudioSource.clip = this.mCurrentBGM;
                bgmAudioSource.Play();

                // active the fade sound in effect.
                mJCSFadeSound.FadeIn(
                    JCS_SoundSettings.instance.GetBGM_Volume(),
                    this.mRealSoundFadeOutTime);

                mDoneFadingOut = true;
            }
            else
            {
                // check if the sound is fade in.
                if (!mJCSFadeSound.IsReachTargetVolume())
                {
                    return;
                }

                // done switching the bgm.
                mSwitchingBGM = false;
            }
        }
        private void Start()
        {
            var sceneS = JCS_SceneSettings.instance;

            // NOTE(jenchieh): get the fade out time base on  the scene setting
            // and scene manager specific.
            float fadeoutTime = sceneS.GetSceneFadeInTimeBaseOnSetting();

            switch (mSwitchSceneType)
            {
            case JCS_SwitchSceneType.BLACK_SCREEN:
            {
                // get the current screen color.
                mBlackScreen.LocalColor = sceneS.SCREEN_COLOR;

                mBlackScreen.FadeOut(fadeoutTime);
            }
            break;

            case JCS_SwitchSceneType.SLIDE_SCREEN:
            {
                mBlackSlideScreen.StartSlideOut(mAlign, fadeoutTime);
            }
            break;
            }

            // Only need to fade BGM when BGM is not switch between scene.
            var soundS = JCS_SoundSettings.instance;
            var soundM = JCS_SoundManager.instance;

            if (!soundS.KEEP_BGM_SWITCH_SCENE)
            {
                if (soundS.SMOOTH_SWITCH_SOUND_BETWEEN_SCENE)
                {
                    // get the component.
                    if (mJCSFadeSound == null)
                    {
                        mJCSFadeSound = this.gameObject.AddComponent <JCS_FadeSound>();
                    }

                    // set the background audio source.
                    mJCSFadeSound.SetAudioSource(
                        soundM.GetBGMAudioSource());

                    // active the fade sound in effect.
                    mJCSFadeSound.FadeIn(
                        soundS.GetBGM_Volume(),
                        /* Fade in the sound base on the setting. */
                        soundS.GetSoundFadeInTimeBaseOnSetting());
                }
            }
            else
            {
                // If the keep bgm is true, we disable it once  everytime a
                // scene is loaded.
                //
                // ATTENTION(jenchieh): This should be place for the last use
                // of the variable 'KEEP_BGM_SWITCH_SCENE'.
                soundS.KEEP_BGM_SWITCH_SCENE = false;
            }

            // the game is loaded start the game agian
            JCS_GameManager.instance.GAME_PAUSE = false;
        }