Squaring the Square

Now that we have one working Square, let's create eight more to fill in the remaining gaps. But before we do that, we should encapsulate the Square in a Prefab, so that any duplicates will share the changes we make.

  1. Create a Prefab and rename it Square.
  2. Drag the Square GameObject from the Hirearchy panel inside the Square Prefab in the Project panel. The Prefab lights up that familiar shade of blue.
  3. In the Scene view, duplicate the first square until you have a total of 9 squares in the grid gaps. An easy way to do this is to duplicate the top-left square twice, and drag the copies to the top-middle and top-right spaces to complete the first row. Then select all 3 squares and duplicate them. Move the three duplicates down to the ...

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.