I’m developing a game that uses the music player from Music player - (load sound files at runtime from directory, and play them) - Questions & Answers - Unity Discussions
(the best answer in c# it’s what i’m using)
It’s great, but in my app, i don’t have a play button on the gui. I want the music to start right away after the “ReloadSounds()” function ends. So, I call the “PlayCurrent();” at the last line of the “ReloadSounds()” function.
The problem is sometimes i get a indexoutofbounds error and it’s because the List clips attribute is empty when i call playcurrent()
Strangely, there’s no problem if i keep the calls to print(); on the function LoadFile(string path) (there are 2 prints on this function, like the example on the link).
I think the error is cause because i start coroutines and i think coroutines in unity are like threads, but people say they’re not and that i shouldn’t worry about thread-safety when i use them.
Is there any way to make my app work without relying on print() calls on the LoadFile(string path) function? Is coroutine a thread on unity?