Time for action – pretty maids all in a row
We're going to create a 2D array referencing our squares in an interesting way. Follow along.
- Create a standard one-dimensional array to hold the squares by adding this declaration to the
GameLogic
script:var XPiece:GameObject; var OPiece:GameObject; var currentPlayer:int = 1; var prompt:GUIText; var aSquares:GameObject[];
- Select the
GameLogic
GameObject. Set the Size of theaSquares
array to9
in the Inspector panel. - One by one, making sure you get all 9 unique squares with no repeats, click and drag the 9
Square
GameObjects from the Hierarchy panel into the array slots in the Inspector panel. Another way ...
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.