This is how I try to load my sprite images:
sprite Sprites[];
void Start() {
...
Sprites = Resources.LoadAll<Sprite>("Card/AnimalImages");
Debug.Log("Sprite name: " + Sprites[8].name);
...
}
But it gives me the error that you can see in the picture below. Note that in the same figure there is a hierarchy of folders on the right side. I put two ellipsis in the code because it is actually much longer than what I posted, but I assure you that the script is correctly attached to the object and it generally works.
The problem is that it doesn't load the sprites as I expect: the debugger hangs at the point where the Debug.Log(...);
is executed (precisely when it tries to access the Sprites vector which is probably empty).
It's the first time in Unity3D where I need to load the sprites in that way. I tried to look in some previous posts, probably I will have missed someone, but in those found until now no one has helped me.
Can someone help me to understand how to load the sprites and especially where is my mistake?
Update
I tried to check if could be a problem of static/dynamic arrays, but it seems not to be a problem of this type, in fact following code:
Sprites = new ArrayList(Resources.LoadAll<Sprite>("Card/AnimalImages"));
Debug.Log("Size of dynamic array: " + Sprites.Count);
prints:
Size of dynamic array: 0