Reputation: 83
I'm trying load in a Sprite Array Sprite, sliced in Editor using code, but sprites. Length always returns 0. A folder named "Sprites" is in Assets' folder and a sliced picture is in Sprites. Why it isn't working?
Sprite[] sprites = Resources.LoadAll<Sprite>("Sprites");
Upvotes: 1
Views: 9242
Reputation: 7824
The Sprites folder must be in the Resources
folder. Like this:
It is also worth pointing out that your code is looking for files that are marked as Sprite
.
Sprite[] sprites = Resources.LoadAll<Sprite>("Sprites");
This means that your pictures must have this format or they won't be added to the array.
Or you could just load them all as Objects like this:
Object[] sprites = Resources.LoadAll("Sprites");
Upvotes: 6