I have a fairly large array of 60 tracks. I need them to play one by one. When the scene changes, the track is also interrupted and the next track is played in turn. That is, in one scene can play 0, 1, 2 items. After switching scenes, 3 should play, and so on. On the Internet I found a function that seems to work the way I want. But I do not quite understand how to call function correctly.
public AudioClip[] clipArray;
public AudioSource effectSource;
private int clipIndex;
void PlayRoundRobin() {
if (clipIndex < clipArray.Length)
{
effectSource.PlayOneShot(clipArray[clipIndex]);
clipIndex++;
}
else
{
clipIndex = 0;
effectSource.PlayOneShot(clipArray[clipIndex]);
clipIndex++;
}