Example #1
0
    public void CreateSound(AudioClip newClip)
    {
        SoundPrefab soundPrefabClass = Instantiate(audioPrefab).GetComponent <SoundPrefab>();

        soundPrefabClass.soundSource.clip = newClip;
        soundPrefabClass.soundSource.PlayOneShot(newClip);
    }
Example #2
0
 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();
     }
 }
Example #3
0
    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);
    }