How to load sprite at runtime from atlas?

Good day to all.

At the moment I am creating the 2d game with quite a lot of art. It is
more than 1k sprites there. It should be possible to load any combination
of pictures at runtime. I’d already implemented all the logic, but have a
trouble that is annoying me.

In the current version all the sprites are inside Resources folder and are loaded

Sprite sp = Resources.Load("name", typeof(Sprite)) as Sprite;

It works fine.

There are almost no POT-size images, so without packing to atlases there
is a huge memory overhead. iOS build takes about 500 Mb on device. That’s
why I want to pack my sprites to atlases. But there is a couple of troubles with

First of all, after enabling, unity’s Sprite packer do not wanna pack my images
to atlases (I specified tags for my sprites). There is nothing happens after
clicking “Pack”/“Repack”. I thought that it is because location of my sprites
(Resources folder), but even after moving them to different folder, Sprite packer
works strange. Anyway, at the moment I created test project, copied all the
pictures there and packed them (still cannot pack them in the original project).

The next trouble, that I cannot find how to load sprites from created atlases
at runtime without assigning them to variables in my scripts.

I cannot find enough info in the official reference and on the forums, as this is
quite a new feature, but hope that someone here can give me needed answers.

Have a nice day and thanks for reading =)

I create a SpriteCollection class

using UnityEngine;
using System.Collections.Generic;

public class SpriteCollection : MonoBehaviour {

    public List<Sprite> sprites = new List<Sprite>();
    public Sprite GetSprite(int index)
        if (index >= 0 && index < sprites.Count)
            return sprites[index];

        return null;
    public Sprite GetSprite(string spriteName)
        foreach(Sprite sprite in sprites)
            if ( == spriteName)
                return sprite;
        return null;

attach it to a game object and save it as prefab. Assign desired sprites to each prefab and then Resource.Load(prefab). Hope this helps!

This is currently not possible, unfortunately.

You might want to help and vote on this feedback issue “Allow access to sprite packer atlas to retrieve sprites by name”

Other related post/answers