Seeing is believing

So far, everything we've done has been theoretical. Our cards exist in some imaginary code space, but we've done nothing to actually draw the cards to the screen. Let's build our OnGUI function and put something on the screen to see where all this is leading.

On the title screen, we used a Fixed Layout to position our Play Game button. We decided exactly where on the screen to put the button, and how big it should be. We're going to build our grid of cards using an Automatic Layout to illustrate the difference.

With an Automatic Layout, you define an area and place your GUI controls inside it. You create your controls using the built-in GUILayout class, instead of the GUI class. The controls that you create with GUILayout stretch ...

Get Unity 4.x Game Development by Example Beginner's Guide 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.