音频剪辑无效。那么如何使用声音元素正确填充数组呢?
请帮我下面的代码:
using UnityEngine;
using System.Collections;
public class Audio_RanGen: MonoBehaviour {
public AudioClip[] sounds;
// Use this for initialization
void Start() {
sounds=new AudioClip[5];
// you would need to create/assign for your audio clip here
}
// Update is called once per frame
void Update() {
}
void OnGUI() {
if(GUI.Button(new Rect(100, 200, 200, 50), "Random Number Genaration")) {
audio.clip=sounds[Random.Range(0, 4)];
print(audio.clip);
audio.Play();
}
}
}