Search Unity

  1. Unity 2020.2 has been released.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Am I missing the plot with Sprite Packer Atlas'

Discussion in 'UGUI & TextMesh Pro' started by PeterD, Oct 31, 2014.

  1. PeterD

    PeterD

    Joined:
    Feb 6, 2013
    Posts:
    120
    I am using sprite packer to pack my sprites and reduce memory footprint for a mobile game but, there seems to be no way to actually use these sprites from the atlas at runtime.

    The usual way would be to do a Resources.Load(blah) as sprite;

    The Atlas isn't in the resources folder so that doesn't work. It therefore stands to reason that there must be another loading command to grab stuff from the library at runtime and return it as a sprite. If not then what is the sprite packer actually meant to be used for. Currently it would imply that you would need to still have the sprites you packed in your scene from the beginning, which defeats all purpose of having them packed somewhere.

    I can't find a single official Unity manual page saying how you load the sprites once packed. Just one telling you how to use the sprite packager and roughly what it does behind the scenes.
     
  2. AlienMe

    AlienMe

    Joined:
    Sep 16, 2014
    Posts:
    74
    From what I've seen:
    • Sprites in the resource folder don't get packed into atlases.
    • Sprites elsewhere get packed as they should.
    • You use the sprite, and never the Atlas, you don't get access to the Atlas (at least not easily)
    If you want to load sprite at runtime, from an atlas, you have two choices (that I know of):
    • Add the sprite(s) to an Asset Bundle. Asset Bundles seem to handle atlases correctly.
    • Add (or use) the sprite to a prefab, and load the prefab from Resources, or from an Asset Bundle.
     
    PeterD likes this.
  3. PeterD

    PeterD

    Joined:
    Feb 6, 2013
    Posts:
    120
    Thanks AlienMe. It's odd that Unity proper doesn't seem to handle it's own atlas' correctly from resources. I would have thought that the sprite system would have routines to grab the sprites from script at runtime using a sprite name or atlas and frame reference. Instead the atlas implementation is hidden like some kind of dark secret.
     
unityunity