void Awake() { if (instance != null) { Destroy(gameObject); } else { instance = this; DontDestroyOnLoad(this); musicSources = new AudioSource[2]; for (int i = 0; i < 2; i++) { GameObject newMusicSource = new GameObject("Music_Source_" + "0" + (i + 1)); musicSources[i] = newMusicSource.AddComponent <AudioSource> (); newMusicSource.transform.parent = this.transform; } library = GetComponent <SFXLibrary> (); } }
public static void Init() { AnimationLibray = new AnimationLibrary(); SFXLibrary = new SFXLibrary(); }
public void SetSound(string soundName) { m_audioSrc.clip = SFXLibrary.GetSound(soundName); }
public void PlayOneShot(string soundName, float volume = 1.0f, float pitch = 1.0f) { m_audioSrc.loop = false; m_audioSrc.pitch = pitch; m_audioSrc.PlayOneShot(SFXLibrary.GetSound(soundName), volume); }