Time for action - create an area to store the grid

Let's create one of these Automatic Layout areas in our GameScript.

  1. We don't need the Update function in this script either. As we did earlier, change Update to OnGUI to create an OnGUI function:
    function OnGUI () {
  2. Begin and end the Automatic Layout area inside the OnGUI function:
    function OnGUI ()
    GUILayout.BeginArea (Rect (0,0,Screen.width,Screen.height));

The area will be the width and height of the screen, and it will start at the screen origin at the top-left of the screen.

These two statements are like bookends or HTML tags. Any UI controls we build between these bookends will be created within the area. Each new control will automatically stack vertically beneath ...

Get Unity 3D Game Development by Example now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.