Пример #1
0
 void Awake()
 {
     if (soundsSource == null)
     {
         DontDestroyOnLoad(transform.gameObject);
         soundsSource = this;
     }
     else
     {
         Destroy(gameObject);
     }
 }
Пример #2
0
        private void Play(VoiceLine line)
        {
            if (Random.Range(0f, 1f) > line.ChanceOfPlaying)
            {
                return;
            }

            SoundsSource.pitch = 1;
            var clip = line.RandomClips.RandomItem();

            SoundsSource.PlayOneShot(clip.audio, line.VolumeScale);

            if (clip.subtitle.IsNullOrEmpty())
            {
                Debug.LogWarning($"the voice line {line.name} doesn't have a subtitle!");
            }
            else
            {
                Subtitles.Say(clip.subtitle, clip.audio.length);
            }
        }
Пример #3
0
 private void Play(SoundEffect sound)
 {
     SoundsSource.pitch = Random.Range(1 - sound.MaxPitchVariation, 1 + sound.MaxPitchVariation);
     SoundsSource.PlayOneShot(sound.clip, sound.VolumeScale);
 }