void Awake() { if (soundsSource == null) { DontDestroyOnLoad(transform.gameObject); soundsSource = this; } else { Destroy(gameObject); } }
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); } }
private void Play(SoundEffect sound) { SoundsSource.pitch = Random.Range(1 - sound.MaxPitchVariation, 1 + sound.MaxPitchVariation); SoundsSource.PlayOneShot(sound.clip, sound.VolumeScale); }