Start me up

Remember that we're building this game with Unity GUI controls. Just as we created a clickable Play Game button on the title screen, we're going to build all of our clickable game cards using the same button control. Our grid of cards will be a grid of GUI buttons aligned on the screen.

Let's add some code to the default Start function to get the ball rolling. Start is another one of those built-in Unity functions that gets called before Update or OnGUI, so it's a good place to initialize some stuff. Type the following code near the top of your script, beneath the list of variables we just declared:

function Start () {
  playerCanClick = true; // We should let the player play, don't you think?

  // Initialize some empty Collections:

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.