public static void VolumeSize(float size) { AudioSource audioPlayer = StaticObject.GetInstance().GetComponent <AudioSource>(); if (audioPlayer == null) { audioPlayer = StaticObject.GetInstance().gameObject.AddComponent <AudioSource>(); } audioPlayer.volume = size; }
public void PlaySounds(string audioIndex) { AudioSource audioPlayer = StaticObject.GetInstance().GetComponent <AudioSource>(); if (audioPlayer == null) { audioPlayer = StaticObject.GetInstance().gameObject.AddComponent <AudioSource>(); } foreach (AudioClip audio in Sounds) { if (audio.name.Equals(audioIndex)) { audioPlayer.clip = audio; audioPlayer.volume = OptionValues.GetVolume(); audioPlayer.Play(); } } }