22 lines
477 B
C#
22 lines
477 B
C#
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 () {
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|