I'm trying to load all my audiofiles to find out how many files I got:
private int GetLength()
{
AudioClip[] array = Resources.LoadAll("Audio/Melody/Test", typeof(AudioClip)) as AudioClip[];
Debug.Log("Length: " + array.Length); // Gets Error here!
return array.Length;
}
My Resourcesfolder look like this: Assets/Resources/Audio/Melody/Test/12 audio files
Error: NullReferenceException: Object reference not set to an instance of an object MelodyCreator.GetLength () (at Assets/Scripts/MelodyCreator.cs:24)
So my question is:
How do I get this piece of code to return the total amount of audioclips I have in a folder?
Spend hours looking for the answer but could not find a answer that worked for me. I Hope someone is able to help me.