public void Play(string name, float vol) { AudThingy sownd = new AudThingy(); foreach (AudThingy t in sounds) { if (t.name == name) { sownd = t; break; } } var soundList = sownd.soundsList; int index = Random.Range(0, soundList.Length); audioSource.clip = soundList[index]; audioSource.PlayOneShot(soundList[index], vol); }
public void Play(string name) { AudThingy sownd = new AudThingy(); foreach (AudThingy t in sounds) { if (t.name == name) { sownd = t; break; } } var soundList = sownd.soundsList; int index = Random.Range(0, soundList.Length); if (soundList[index] == null) { throw new System.Exception("Sound" + index + " not found"); } audioSource.clip = soundList[index]; audioSource.PlayOneShot(soundList[index], sownd.volume); }