using UnityEngine; using System.Collections; public class SoundPlayer : MonoBehaviour { public AudioClip[] sounds; private AudioSource audioSource; // Use this for initialization void Start () { audioSource = gameObject.GetComponent(); if (sounds != null && audioSource != null) { AudioClip sound = sounds[Random.Range(0, sounds.Length - 1)]; audioSource.PlayOneShot(sound); } } // Update is called once per frame void Update () { } }