public void PlaySound1(LessonStepID soundName, Action callback = null) { //var cancel = Observable.FromCoroutine(PlaySoundRoutine).Subscribe().AddTo(this); if (cor != null) { StopCoroutine(cor); cor = null; } cor = StartCoroutine(PlaySoundRoutine(soundName, callback)); }
public void PlaySound(LessonStepID soundName, Action callback = null) { Sound sound = soundLibrary.Data.Find(item => item.lessonStepID == soundName); audioSource.volume = sound.volume; //audioSource.PlayOneShot(sound.audioClip); foreach (var item in sound.audioClips) { audioSource.PlayOneShot(item); } }
public IEnumerator PlaySoundRoutine(LessonStepID soundName, Action callback = null) { Sound sound = soundLibrary.Data.Find(item => item.lessonStepID == soundName); audioSource.volume = sound.volume; foreach (var item in sound.audioClips) { audioSource.PlayOneShot(item); yield return(new WaitWhile(() => audioSource.isPlaying)); } callback(); }
public Sound(LessonStepID lessonStepID, AudioClip[] audioClips, float volume) { this.lessonStepID = lessonStepID; this.audioClips = audioClips; this.volume = 1; }