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.
- Create a new GUI Text.
- Position it at
0
,1
,0
with a font size of36
. - Rename it as
Prompt
. - Store a reference to it in the
GameLogic
script:var XPiece:GameObject; var OPiece:GameObject; var currentPlayer:int = 1; var prompt:GUIText;
- Save the script.
- Select the
GameLogic
GameObject. - Drag the
Prompt
GUIText GameObject into theprompt
variable ofGameLogic
in the Inspector panel. - 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.