Resources.Load() doesn't work unless load path is hard coded.
I have been making a system that allows for me to load different music tracks.
In a text file i have all the necessary load paths for each track in the resources folder, each of them are slightly different based on what music track it is.
I load the text file and turn the text file into an array of strings, then I attempt to load an audio clip from another part of resources based on one of the load paths in that array. This doesn't work, but when I take the load path and hard code it into the resources.load function it works.
here's the example code that isn't working. No errors are thrown for this at all
Here's the example code that does work, the only difference is that the load path is hard coded, even though it's copied directly from the array of strings
NOTE: The part where it says newLoadMusic = chosenTracks.Loadpath should actually be newLoadMusic = loadedTracks[i].Loadpath. This also still doesn't work
Is there something wrong with the way this has been coded, if so should i avoid using text files to keep load paths saved? Any ideas or help are greatly appreciated
Answer by ToastHatter · Nov 24, 2020 at 12:54 AM
Fixed it!
Turns out there was an invisible character (most likely an \n) which prevented the load path from working, simply using the .Trim() function on the string prevented this from happening