//API--------------------------------- public static void ChangeMusic(AudioClip clip, AudioConfig config) { musicSource.Stop(); musicSource.clip = clip; config.ApplyTo(musicSource); musicSource.Play(); }
public static void PlaySound(AudioClip clip, AudioConfig config) { var source = audioObject.AddComponent <AudioSource>(); config.ApplyTo(source); source.outputAudioMixerGroup = Setting.soundGroup; source.Play(); if (config.loop) { soundsLooping.Add(source); } else { soundsPlaying.Add(source); DelayAction(clip.length, () => { soundsPlaying.Remove(source); MonoBehaviour.Destroy(source); }); } }