So if you have an intro part of the song and a looped part of the song for your Unity project (such as free songs from Wingless Seraph) (as 2 songs), I have written code in how to make them work (first play the intro then play the looped part indefinitely.
Here is the code:
- public AudioSource musicSources;
- private bool stop = false;
- void Start()
- musicSources.Stop(); //So it won’t automatically start
- void Update()
- if (!musicSources.isPlaying && !stop)
- Debug.Log(“Stopped intro music and started the loop”);
- stop = true;
Have 2 Audio Source components. Set one for the intro song and one for the loop song. Set the loop check-mark true of the Audio Source of the loop. Then in the script, put the intro song into first field asking for the Audio Source, and the loop into the second one.
Set the first Music Time to however long the intro song lasts, in seconds as a decimal.