RetinaPro for NGUI - Easy management of multiple devices pixel / screen resolutions

Very excited that our first Unity Asset Store tool is now available!

RetinaPro for NGUI On Unity Asset Store

I’ve been using this tool (or more accurately a version of it) for quite a while now and decided it was worth submitting to the Asset Store. If you are a user of NGUI (which is my fav. 2D SDK) you’ll know that when maintaining your atlases it’s easy to make mistakes especially if you have to consider 5 different sets of art (e.g. iPhone, iPhone@2x, iPad, iPad@2x, iPhone-568h@2x).

It’s saved me 100’s of hours across multiple projects by making it really easy to update / refresh all of the art assets per device into their respective atlases.

Feedback is appreciated. I’d like to make this the best tool that it can be.

Hi Ian,this looks very interesting,and could potentially save me a ton of time on my project,as unfortunately I dont get to work with Unity fulltime :slight_smile: Im hoping to deploy my app on android as well as iOS platforms.In your description I don’t see any specific reference to android devices,so Im just wondering is it possible to configure atlases for android devices also? Thanks in advance!

Thanks for your interest. I haven’t specifically mentioned Android devices in the description because unfortunately it’s not something I can easily test. However, it should work - there aren’t any specific iOS requirements. It’s all data driven using data the user supplies, so I’d say go for it. If you do run into issues contact me at the support email address and I’ll do my very best to resolve your issue ASAP.

Hii it sound really cool. Does it work with FastGUI?

Thanks. I’ve never used FastGUI before. However, if you can control the destination asset folder that FastGUI copies your files to then I’m guessing you can.

RetinaPro requires the following folder structure:

Assets/Textures/rp_atlases/<device_name>//file.png

Where ‘file.png’ is an art resource. FYI, to support the way NGUI handles atlas references (allowing you to swap device types at runtime) each atlas must contain the same filenames. e.g. if you have an image called ‘button.png’ for one atlas/device then all device versions of that atlas must share that same filename. This is because the sprite holds a reference of the image name and when you swap out the atlas it needs to be able to find that same image (albeit in another atlas at a different size).

Note: RetinaPro comes with a runtime script that handles all the atlas reference loading / swapping so you don’t have to worry about the details. The included example scene shows how this works.

FWIW, you can modify the base Texture folder for RetinaPro if you’re ok with changing the RetinaProConfig script. Note: future versions of RetinaPro will likely expose this via the GUI.

	public const string atlasTextureFolder = "/Textures/rp_atlases/";
  • Switched retina pro data file from binary to xml (makes it easier when
    working with teams / merging).
  • Upon pressing the 'Update button (see any RetinaPro window), any
    previous binary RetinaProBinData.txt file will be updated to the xml
    version.
  • Fixed get_dataPath error.

This works on Android?
Can I use it on different Android aspect ratios?

Previously I said this. Give it a try and contact me if you run into issues.

I am getting a ton of MissingReferenceException errors on Unity 4.1 and NGUI 2.3.6 when I am trying to create the atlases. Any idea why this might be happening?

The errors are:

MissingReferenceException: The object of type ‘Material’ has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
UnityEngine.Material.get_mainTexture () (at C:/BuildAgent/work/7535de4ca26c26ac/Runtime/ExportGenerated/Editor/Graphics.cs:1605)
UIDrawCall.Set (.BetterList1 verts, .BetterList1 norms, .BetterList1 tans, .BetterList1 uvs, .BetterList`1 cols) (at Assets/NGUI/Scripts/Internal/UIDrawCall.cs:251)
UIPanel.Fill (UnityEngine.Material mat) (at Assets/NGUI/Scripts/UI/UIPanel.cs:941)
UIPanel.LateUpdate () (at Assets/NGUI/Scripts/UI/UIPanel.cs:993)

NullReferenceException: Object reference not set to an instance of an object
BetterList`1[UnityEngine.Material].Contains (UnityEngine.Material item) (at Assets/NGUI/Scripts/Internal/BetterList.cs:216)
UIPanel.UpdateWidgets () (at Assets/NGUI/Scripts/UI/UIPanel.cs:851)
UIPanel.LateUpdate () (at Assets/NGUI/Scripts/UI/UIPanel.cs:983)

FWIW, I spoke with aikitect over email and the issue seems related to atlas names that contain spaces. aikitect removed the spaces and it fixed the issue. Having said that I did try to reproduce the issue here and could not.

We just bought it, and have already some issues, it’s giving me issues with UIFont.cs. We are using Dynamic Font, so we modified the C# script.

This is the issue:
Assets/RetinaPro/Editor/retinaProAtlasWindow.cs(320,46): error CS1061: Type UIFont' does not contain a definition for pixelSize’ and no extension method pixelSize' of type UIFont’ could be found (are you missing a using directive or an assembly reference?)

What version of NGUI are you using? Versions prior to NGUI 2.3.2 require a fix made to a few of NGUI’s scripts. The details are in the readme.txt file included with the RetinaPro package. One of those fixes is to add the pixelSize functionality to UIFont.

Ohh, sorry, I did that and try to open Windows/RetinaPro/Devices and Unity crash, doesn’t say anything, just stay freeze and “Not responding”

Sorry you’re having issues.

First of all, please send me the RetinaPro/Resources/RetinaProData.txt file to the support email address (see the readme.txt).

Given that you’ve modified RetinaPro and had an older version of NGUI installed. Can I ask you to try the following?

  • Open a new blank / scene.
  • Delete the RetinaPro folder from your Asset folder
  • Update NGUI to latest version (I think it’s 2.3.6)
  • Reinstall the RetinaPro package

Fantastic plugin, this was exactly what I was after! Thanks for making this.

I have a question, I havent tested this yet, just got started setting it up, but can I use several fonts with this? I need to use at least two fonts for my game, so can I just add font atlases to Retina Pro and it will automatically work? Can I combine them all into one font atlas to reduce draw calls?

You’re welcome!

Right now RetinaPro only supports one font per font atlas. So yes, you can use as many fonts as you want, but you can’t currently combine them into a single atlas. In practice I’ve never found this to be a problem but I do understand your needs may be different.

Just add a new atlas and check the isFont for each font you want to add.

Great, that sounds good! I will just create more atlases then.

One more question, in your example, I see you have set NGUI’s Scaling Style to “FixedSize” instead of “FixedSizeOnMobiles”. Is it more ideal to use the latter for mobile, or should I set it to FixedSize too?

That option on NGUI’s UIRoot script controls how it calculates the ‘height’ using minimum height, maximum height and manual height properties. RetinaPro sets all three properties to the device setting height. In that case setting it to ‘FixedSize’ is the same as selecting ‘FixedSizeOnMobiles’ and just setting the manual height property. If I get use cases from yourself or other customers where we need more control here I will add that functionality.

Thanks! That clears that up.

Another issue; when using the iPhone @x2 preview in Unity, the preview gives me gigantic images which are almost the same size as the iphone standard. The iPad and iPad x2 previews are however perfect. This makes it a bit hard to evaluate my work for the iPhone in the editor, but is there a way around this?

Also: when setting the Preview to @iPhone x2 , the manual/min/max height goes to 320, shouldn’t it be going to 640?

What are the settings / values of the “@iPhone x 2” device?