i need to generate 10 audio files randomly…so i.m trying to use the below code it is sufficient or is there any alternate if there plz help me…
using UnityEngine;
using System.Collections;
public class Audio_RanGen : MonoBehaviour
{
public AudioClip[] sound=new AudioClip[3]{CowboyRap,New_Biker_Rap-click_mix,Jimmy_Reggae};
// Use this for initialization
void Start ()
{
}
// Update is called once per frame
void Update ()
{
}
void OnGUI()
{
if(GUI.Button(new Rect(100,200,200,50),"Random Number Genaration"))
{
for(int i=0;i<3;i++)
{
print ("hiiii");
print(sound.Length);
print(sound[0]);
audio.clip=sound[Random.Range(0,sound.Length)];
audio.Play();
}
}
}
}