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.

December 3rd, 2012 | Comments (0)

UIToolkit Buttons and Unity WebPlayer

Ran into a problem the other day when publishing a Unity game to Webplayer – all of my UIButtons were broken and not detecting clicks. After a bit of a search, I came across a solution on Github posted by a chap called hyakugei.

Basically it involves using a wrapper around Touch instances to fake them when a touch is detected, as for some reason they don’t get picked on WebPlayer builds.

You can either download his branched UIToolkit, or, as I did run through the list of changes and add them manually. I picked this route because my UIToolkit is already heavily customised. Works like a charm.

October 23rd, 2012 | Comments (0)