GameObject[,] board = new GameObject[10, 10]; for (int i = 0; i < board.GetLength(0); i++) { for (int j = 0; j < board.GetLength(1); j++) { // Create a new game object for each cell of the board board[i, j] = new GameObject(); } }
for (int i = 0; i < board.GetLength(0); i++) { for (int j = 0; j < board.GetLength(1); j++) { // Move the game object to a new position board[i, j].transform.position = new Vector3(i, j, 0); } }
for (int i = 0; i < board.GetLength(0); i++) { for (int j = 0; j < board.GetLength(1); j++) { // Destroy each game object Destroy(board[i, j]); } }This code destroys all the game objects in the board. The GameObject[,] class is part of the Unity engine's library in the UnityEngine namespace.