public void CreateSound(AudioClip newClip) { SoundPrefab soundPrefabClass = Instantiate(audioPrefab).GetComponent <SoundPrefab>(); soundPrefabClass.soundSource.clip = newClip; soundPrefabClass.soundSource.PlayOneShot(newClip); }
public static void CreateFromPrefab(SoundPrefab sound, Vector3 pos, SoundPrefab.Materials soundMaterial, float volume = 1) { if (sound != null) { SoundPrefab i = (SoundPrefab)Object.Instantiate(sound, pos, Quaternion.identity); i.SetSoundMaterial(soundMaterial); i.audio.volume = volume; i.audio.Play(); } }
public bool GetSoundFromSoundList(SoundName sound, SoundPrefab[] list, out SoundPrefab prefab) { foreach (SoundPrefab cue in list) { if (cue.name == sound) { prefab = cue; return(true); } } prefab = new SoundPrefab(); return(false); }