public void PlaySound(UnitTypes unitType, UnitSoundType soundType) { AudioClip[] audioClipArray = soundsDictionary[unitType][soundType]; var ran = new System.Random(); int randomNumber = ran.Next(audioClipArray.Length); if (audioSource == null) { audioSource = Camera.main.gameObject.AddComponent <AudioSource>(); } if (!audioSource.isPlaying) { audioSource.clip = audioClipArray[randomNumber]; audioSource.Play(); } }
public void PlaySound(UnitSoundType soundType) { //GameObject.Find("_Scripts").GetComponent<GameManager>().UnitSounds.PlaySound(UnitGameObject.type, soundType); }