- Home /
Reference Specific Sprites from Atlas
Hi guys! I know it's already been asked but, instead of helping me, the replies given to this kind of questions have confused me even more!
So, I've got an Atlas sliced and inside it I've got some sprites... which are " packed". Reference/Docs specifically says that, with packed sprites, this:
private SpriteRenderer mySP;
Texture2D tex = mySP.sprite.texture;
Debug.Log("TEX IS:"+tex);
won't point to one Sprite but instead to the Atlas in which that one is packed along the others. ( the SpriteRenderer takes its Sprites from an Atlas)
So what would I need to do to access via code a specific Sprite inside that Atlas, aside from re-importing my sprites as single images?
I've been trying with this:
List<Sprite> listSprite = new List<Sprite>();
listSprite.AddRange(Resources.LoadAll<Sprite>("AtlasName"));
Debug.Log ("listSprite count ="+listSprite.Count);
But the Count returns 0, so I guess I've missed something...
Thanks for your time!
Answer by esitoinatteso · Dec 27, 2014 at 11:03 AM
I guess an answer like THIS would be legit! Feel free to elaborate or suggest other ways around if you want, I'll accept that as an answer in a week or so if nothing beefier shows up!