Example #1
0
    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));
    }
Example #2
0
    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);
        }
    }
Example #3
0
    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();
    }
Example #4
0
 public Sound(LessonStepID lessonStepID, AudioClip[] audioClips, float volume)
 {
     this.lessonStepID = lessonStepID;
     this.audioClips   = audioClips;
     this.volume       = 1;
 }