Wednesday, October 23, 2013

Unity and GUI scaling, the easy way...

Today's update is about GUI design in unity, and some ideas on how to make it a bit less annoying to use.

Anyone using the GUI system knows that it can be tough to make it work with multiple resolutions and aspect ratios.  In fact, this issues is the lead one clients come to me about when working with the GUI system.  Well, after "What do you mean Unity does not have a built in GUI editor?"...

Well, there is an easy method to deal with that.  Using the GUI.matrix variable.

The idea is to set a variable with the default width and height of the screen in pixels you want to design for, in this case, 1920x1080.  Once you know that, you build your interface based on the idea that EVERYONE will use that resolution.

Then at the beginning of every OnGUI() call, you just set the GUI.matrix and it will do all the hard scaling changes for you.

Example below:

No comments:

Post a Comment