Pawelsar1
Pawelsar1

Reputation: 83

Resourses.LoadAll not working

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

Answers (1)

axwcode
axwcode

Reputation: 7824

The Sprites folder must be in the Resources folder. Like this:

enter image description here

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.

enter image description here

Or you could just load them all as Objects like this:

Object[] sprites = Resources.LoadAll("Sprites");

Upvotes: 6

Related Questions