*
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class SoundPlayer : MonoBehaviour {
|
||||
public AudioClip[] sounds;
|
||||
private AudioSource audioSource;
|
||||
|
||||
// Use this for initialization
|
||||
void Start () {
|
||||
audioSource = gameObject.GetComponent<AudioSource>();
|
||||
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 () {
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user