- Home /
Question is off-topic or not relevant
Audio after Audio Loop
Hello everyone,
im just new to the programming "in unity" so i was trying to pull some script off but im not sure how would i ..
I'd like a script that goes as the A specific music (Track 1) plays when the game starts.
After 5 Minutes: When the 1st Track ends, then another music plays (Track 2) (if the 1st track not finished when it to be finished then play)
After 10 Minutes: When the 2nd Track ends, then another music plays (Track 3) (if the 2nd track not finished when it to be finished then play)
note: C# Script
Closed for asking for code : I'd like a script that ... , note: C# Script
Sorry, but your question is not suitable for Unity Answers. Please use the Unity Forum for discussions such as "How to ...". Unity Answers is here to help you solve any specific problems you have.
Answer by fafase · Aug 25, 2013 at 02:43 PM
You place all of your audio clips in an array, and you play them one after the other. Like a playlist.
void Update()
{
if(!audio.isPlaying){
if(++index == array.Length)index = 0;
audio.clip = array[index];
audio.Play();
}
}
You still need to declare the array of AudioClip, make it public so that you can drag and drop files into the slots of the inspector. You also need declare index.
This will restart the playlist from the beginning once you reach the end of it.