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 AssetDatabase.LoadAllAssetsAtPath not loading asset - Questions & Answers - Unity Discussions however the answers provided don’t work for me either