- Home /
Unity3d Resources.LoadAll empty array
In my resources folder structure I have myself a file, now in the unity editor this file is a Texture Type Sprite (2D and UI)
, now when I attempt to run this code in one of my scripts
var icons = Resources.LoadAll<Sprite>("Images/BuffIcons");
My icons variable is empty, now if I change the line above to
var icons = Resources.LoadAll("Images/BuffIcons");
It comes back with an array which has a Texture2D
and then multiple Sprite
objects. Now why can't I cast the objects to a Sprite
?
Also just for your information the Sprite (2D and UI)
is a Multiple
sprite so this sprite in total has like 42 different sprites. It seems to me the sprite which holds all the other sprites is classed as a Texture2D
and then all the sprites inside of the Texture2D
are Sprites. How can I just tell the Resources.LoadAll to load the sprites?
Basically the same problem as this user http://answers.unity3d.com/questions/900990/assetdatabaseloadallassetsatpath-not-loading-asset.html however the answers provided don't work for me either :(
Answer by Kutiman · Mar 27, 2016 at 08:18 PM
var icons = Resources.LoadAll("path_name", Sprite);
that should do it, but if not, you can always just remove the first item from the list and it'll work just fine (though ugly...)
Your answer
![](https://koobas.hobune.stream/wayback/20220612073250im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to get the number of subfolders within a subfolder within resources? 0 Answers
Manually changing between sprites in a spritesheet 0 Answers
Dynamic setting of sprites cause many draw calls 0 Answers
How to load sprites into array Sprite[] in Javascript 2 Answers
Resource.Load returns null on sprite 1 Answer