Time for action – designer to player. Come in, player.

Most people over the age of zero know how to play Tic Tac Toe, but just to be safe, let's rig up a down-and-dirty onscreen prompt to let the players know whose turn it is.

  1. Create a new GUI Text.
  2. Position it at 0,1,0 with a font size of 36.
  3. Rename it as Prompt.
    Time for action – designer to player. Come in, player.
  4. Store a reference to it in the GameLogic script:
    var XPiece:GameObject;
    var OPiece:GameObject;
    var currentPlayer:int = 1;
    var prompt:GUIText;
    
  5. Save the script.
  6. Select the GameLogic GameObject.
  7. Drag the Prompt GUIText GameObject into the prompt variable of GameLogic in the Inspector panel.
  8. Back in the GameLogic script, create a function, as follows, ...

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.