IEnumerator Fadein(FadeAudioInfo info) //AudioSource audioSource , int targetVolulme ){ { info.audio.enabled = true; int vol = 0; int targetVolume = (int)(info.volume * 100); for (; vol < targetVolume; vol++) { // Debug.Log( "Fadein.." ); info.audio.volume = (float)vol / 100; yield return(null); } info.audio.volume = info.volume; }
public override void PlayMusic(string path, bool loop, float xchbgmTime = 0f) { if (currentAudio != null) { StopMusic(xchbgmTime); } float volume = ViNoConfig.prefsBgmVolume; GameObject sourceGO = new GameObject(path); AudioSource source = sourceGO.AddComponent <AudioSource>(); currentAudio = LoadAudioClipAndPlayDelayed(source, path, volume, xchbgmTime, loop); currentAudioKey = path; // Fadein Music. #if false FadeAudioInfo info = new FadeAudioInfo(); info.audio = currentAudio; info.volume = volume; StartCoroutine("Fadein", info); #endif }
IEnumerator Fadein ( FadeAudioInfo info ){//AudioSource audioSource , int targetVolulme ){ info.audio.enabled = true; int vol = 0; int targetVolume = (int)( info.volume * 100 ); for (; vol<targetVolume; vol++) { // Debug.Log( "Fadein.." ); info.audio.volume = (float)vol / 100; yield return null; } info.audio.volume = info.volume; }
public override void PlayMusic( string path , bool loop , float xchbgmTime = 0f ){ if( currentAudio != null ){ StopMusic( xchbgmTime ); } float volume = ViNoConfig.prefsBgmVolume; GameObject sourceGO = new GameObject( path ); AudioSource source = sourceGO.AddComponent<AudioSource>(); currentAudio = LoadAudioClipAndPlayDelayed( source , path , volume , xchbgmTime , loop ); currentAudioKey = path; // Fadein Music. #if false FadeAudioInfo info = new FadeAudioInfo(); info.audio = currentAudio; info.volume = volume; StartCoroutine( "Fadein" , info ); #endif }