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 to accomplish this in a single shot is to leave the array size at0
, and then select theGameLogic
GameObject and lock the Inspector (click the little lock icon at the top right of the panel). With theGameLogic
Inspector locked, you can select all the Squares and drag them en masse onto the array in the Inspector panel.We're part of the way there...