GUI Layouts

We now understand what a GUI Style is, how a GUI Skin allows you to use a collection of Styles, and the different types of GUI Controls we can use and their purpose. Next is laying them out on screen in the correct position and spacing we call for.

The OnGUI() function allows two types of layout styles: the Automatic Layout and the Fixed Layout.

Automatic Layout

The Automatic Layout does not use positioning to place the elements of your GUI. This is useful if you are not certain of the look you are trying to create or you do not know the exact number of elements that you will need in your GUI. An example of this type of use might be if your game lets you pick up an infinite number of items, and you wish to show them in the GUI. Since ...

Get Learning 2D Game Development with Unity®: A Hands-On Guide to Game Creation now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.