Q:

how to play random music Unity

 using UnityEngine; using System.Collections;  public class RandomAudio : MonoBehaviour {     public AudioClip[] soundtrack;      // Use this for initialization     void Start ()     {         if (!audio.playOnAwake)         {             audio.clip = soundtrack[Random.Range(0, soundtrack.Length)];             audio.Play();         }     }          // Update is called once per frame     void Update ()     {         if (!audio.isPlaying)         {             audio.clip = soundtrack[Random.Range(0, soundtrack.Length)];             audio.Play();         }     } }
0

New to Communities?

Join the community