Pixel Perfect UI

Hi,

So, ive been wondering how we would go about creating a pixel perfect UI? For example, on iOS, if we wanted to use standard and retina assets, is there an “easy” way to do this using the new UI system?

I have been using RetinaPro (NGUI) for a while now, and it works quite well. Its a great atlas switching solution, and will render the assets pixel perfect depending on what device we are running on. However, the new UI system automatically uses atlases behind the scenes, rather than being able to select an atlas you wish to use, and then choose a sprite from that atlas.

Would we have to do the following to achieve what I am after:

  • Detect which device we are running on, and determine the folder containing all sprites we wish to use (standard or retina)
  • Find all canvas components in the scene
  • Find all Image components under each canvas
  • Go through the sprites in the folder (Step 1) and replace the sprite associated with the Image component with its new one from the sprites folder.
  • Correct the Canvas Reference Resolution to be associated with the current device resolution

I dont know if I am “overthinking” things here, or if there is another solution, but it would be good to get peoples feedback on this. If the new UI system handles displaying the lower resolution sprites so they look “sharp” across all devices, then thats great and I dont have to worry. But it would be good to know!

Adam

For now your solution is a decent one. It will work. Be aware that in the future we will be making improvements to this workflow as we get better asset bundle support.

1 Like

Thanks for the update. I think I may try and implement such a solution, im just concerned it will have a slight performance impact when it runs, but hopefully it should not be noticeable if its run on startup.

Regarding your improvements, will this make it easier to do “atlas switching”? Or do you have a plan to support this within the system?

Yes it will be a system that supports asset localisation and HD/SD ect. It will be built on top of the new Asset Bundle stuff coming in Unity 5. I don’t think there is a blog post about it yet but I think there will be before we launch 5.

Ah, brilliant. Not sure its worth me creating a system for this yet then, will wait and see whats coming. Thanks!