Blog

UIToolkit Camera Fix

prime31’s UIToolkit is still my choice for all things UI in Unity, primarily because its free, and also because I haven’t found a task yet that it can’t do straight out of the box or with some minor code tweaks.

Annoyingly after upgrading to Unity 4, it didn’t seem to work properly on mobile. It looked like the camera wasn’t setting the correct positions for the Touch Areas on initialisation, and graphics were all over the place. Luckily a helpful guy over on the Unity forums posted a fix.

in UI.cs, change _uiCamera to be a static variable, and create a new function called setSize:

And then call UI.setSize() once the scene has loaded.

Leave a Reply