getting single sprite from a sprite multiple.

Hey guys, I know this question has been asked before, however it seems every time the question is asked, it isn’t properly answered, is too specific or the answer just seems illogically complex.

All I want is to know how to get a single sprite from a multiple type sprite(Sprite sheet).
For example I want to get the sprite named ‘FireBall’ from my ‘AbilityIcons’ spritesheet, I hoped that unity designed spritesheets to act like folders, but that doesnt seem to be the case (unless I’ve made a mistake).

example ( Resources.Load (“FireBall”) as Sprite; ) wouldn’t work

and navigating inside the spritesheet doesn’t seem to work

example (Resources.Load (“AbilityIcons/FireBall”) as Sprite;)

I just want to know the simple solution on how to get the texture… or else unless I drag spritesheet sprites around in editor, they are redundant.

Thanks for your time,
Bazza Lisk.

Resources.LoadAll<Sprite>("name of texture") loads and returns all sprites in an atlas. You can loop over that list to find the one you want or use Linq.

using System.Linq;

// Load all sprites in atlas
Sprite[] abilityIconsAtlas = Resources.LoadAll<Sprite>("AbilityIcons");
// Get specific sprite
Sprite fireBallSprite = abilityIconsAtlas.Single(s => s.name == "FireBall");

This is as simple as it gets. Make sure you unload the unused sprites.