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?

So this is a really silly answer however I'm not going to delete this question because around the web I have seen this question in a view places and all the answer's didn't work for me so. Here is my fix :D

Basically I have a Sprite (2D and UI) file in Assets/Resources/Images/BuffIcons, in my code I have this line

BuffIconSprites = Resources.LoadAll<Sprite>("Images/BuffIcons");


Basically all I had to do was simply close Unity and re-open it, it seems if you create the sprite asset which contains multiple sprites you need to close and reopen Unity, I think this is something to do with the solution file which is constantly updated when stuff changing in your Unity file.

P.S. as you can see the line of code I provided hasn't changed. So I'm 100% sure this problem is something to do with the Unity solution

Going to Unity's menu system, selecting Assets and then Reimport All will do the trick.

This better than re-opening unity, since that does not always reimport your assets fully when the project is in a funny state. This will ensure all such issues are corrected. (Just had this issue, and opening / closing did not help - Resources.LoadAll() failed to load anything until Reimport All was used. Checked textures after first close/reopen and they were in an unreadable state in Project tab).