New asset bundles variants (5) and Unity UI spritePacker

Hi all,

We are working on a mobile game (iOS/Android) using Unity 5 and Unity UI.

What we want to do is the following:

  • have 2 sets of UI textures for different screen resolutions (low-res/high-res)
  • pack all UI textures within a single set into an atlas using the Unity SpritePacker (so one low-res atlas and one high-res atlas)
  • pack the atlases into an assetbundle to be downloaded at runtime based on the device (so there is only one of the low-res/high-res atlases on device when running)
  • have prefabs in the app (not in an asset bundle) that reference the correct sprite from the atlas in the asset bundle

The reason why we are doing that is to (a) get pixel perfects icons in all resolution and (b) use only as much memory as is strictly necessary for that resolution.

I am looking at the new assetBundle variants and the spritePacker as a way to do that. There is no documentation specifically on that workflow and I have a few questions based on what I am seeing so far.

First:

I cannot use the CanvasScaler because this means either (a) high-res assets scaled down on low-res devices (too much memory on low-res devices) or (b) low-res assets scaled up on high-res devices (which means scaling artifacts)

Second:

To create a sprite atlas, I need to specify the name of the atlas in Packing Tag for that specific sprite. However, if I use the same name for my low-res and high-res folders, all the resolutions end up packed in the same atlas, which is not what I want as low-res devices will end up with a gigantic atlas containing high-res assets (and these devices tend to be lower on memory).

If I provide different names for the atlases, my understanding is that assetBundles variants will not work as the variants are supposed to be “identical” (which I understand to mean, the assets need to have the same names and sub-folders, but not the same root folder, for instance low-res/folder/a.png and high-res/folder/a.png)

Third:

I cannot work around the asset bundle creation if I want to use the new asset bundle pipeline (which I do) because (a) the documentation indicates that mixing the two is a bad idea and (b) I need the new system for the myriad other resolution-specific assets we need to download for the game.

I am curious if this is a tested scenario for Unity 5 and if there is a recommended solution to meet the goals above.

Variants and atlases don’t seem like they can work together, the documentation for multi-resolution UI only deals with layout and anchoring, not image substitution which is needed for pixel perfect icons on all resolutions, and finally the demo scene for asset bundle variants shows how to swap materials referenced in a scene and doesn’t deal with atlases.

Thanks,

Stephane

http://docs.unity3d.com/Manual/BuildingAssetBundles5x.html
This doc shows how to create identical variants in Unity5