Retina textures using Sprite Packer?

The new sprite packer feature in 4.3 Pro is great. However how can we do higher res versions of textures and include them as part of a packed atlas, so that you can swap the texture on the new 2d sprites but retain the size?

So I build my sprites at normal res, sprites are tagged which makes the atlas with sprite packer. But now I need to make a higher res version of the atlas using retina sprites?

Thanks!

p.s I wasn’t sure if I should post this in the forum or answers, had already posted there but no response
http://answers.unity3d.com/questions/577634/retina-textures-on-43-2d-sprite-packer.html

I believe the only options at the moment is to make a separate atlas for your hi-res sprites and reference that instead of the other one when you detect a retina device.

so i made two sets of textures, normal and hd.

With the normal sprites I gave them the packing tag “levelOne” and the retina sprites packing tag “levelOne-hd”, when I run I can see the atlases in the Sprite Packer window, however the sprites aren’t in the same positions on the sprite sheet between normal hd, so I can’t really swap the texture for the material as the sprite location is wrong.

Any thoughts Unity team? thanks

another question, according to

“Atlases are cached in Project\Library\AtlasCache.”

How can these textures be loaded at runTime to be used for swapping with retina assets?

“Only the required atlases are loaded.” does that mean in the editor, or in the game builds?

Thanks

Currently the workflow is to swap the Sprites rather than the atlas textures they’re using. You should have matching sprites for your normal and hd assets.
It’s not ideal and we’re working on improving this case!

Is there any way to swap them before they get loaded into memory?

I tried swapping the sprites for lower resolution sprites in Awake().

Profiling on iOS, I noticed asset RAM usage spikes up to e.g. 300 MB (i.e. larger textures) when the level loads and then falls down to e.g. 250 MB (smaller textures).

I would like to avoid that because otherwise we have memory pressure crashes on older iPad2’s.

Also, I don’t want to mess with our pipeline by using asset bundles or such …

void Awake()
{

SpriteRenderer sr = (GetComponent<SpriteRenderer> ());

string path = sr.sprite.name;
string newName = "lores/" + path + "_lores";

Sprite newSprite = Resources.Load (newName, typeof(Sprite)) as Sprite;

Sprite oldSprite = sr.sprite;

if (newSprite != null) {
     sr.sprite = newSprite;
}    

Resources.UnloadAsset (oldSprite);

System.GC.Collect ();
}
1 Like

Everybody hates this answer, but the 2Dtoolkit plugin will do this automatically for you :wink: