Resource.load returns null 3 out of 100 times
I have the following code to load and play an .mp3 file from my Resources folder This code should work correctly with 100 .mp3 files. But for some reason it works only with 97 out of those 100 Then there are only 3 .mp3 files that for some reason are not loaded at runtime when I use that method (the variable "audioClip" is set to null when the .mp3 is not loaded)
List of things I already tested/verified: - That the .mp3 files are in my "Sounds/Gua/" path. - That the path to the .mp3 file is correctly written in the Resources.Load method. - I checked that the size of the .mp3 file is not too big (each one is 0.5MB or less). - I checked that the asset import options in Unity are the same for all .mp3 files. - I even re-recorded the .mp3 to make sure it's not corrupted and anyway Unity still doesn't load it.
As I said, my code works with 97% of the cases. Please help!
AudioClip audioClip;
audioClip = Resources.Load<AudioClip>("Sounds/Gua/intro_test"); // Or other .mp3 file path
if (audioClip != null)
{
audioSource.clip = audioClip;
audioSource.Play();
}
else
{
print("! Audio not found");
}
Your answer
Follow this Question
Related Questions
Why am I getting a null reference error? 1 Answer
NullRefrenceException: Object refrence not set to an instance of an object. 0 Answers
ArgumentNullException: Value cannot be null when slicing mesh 0 Answers
Why am I getting this error with my BannerAD (Admob) 1 Answer
The object of type 'GameObject' has been destroyed but you are still trying to access it. 0 Answers