O'Reilly logo

Unity 3D Game Development by Example by Ryan Henson Creighton

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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));
    GUILayout.EndArea();
    }
    

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required