/// <summary> /// Instantiates Tile Objects to visualise the grid and sets up the <see cref="m_AvailableCells" /> /// </summary> protected void SetUpGrid() { PlacementTile tileToUse; tileToUse = placementTilePrefab; if (tileToUse != null) { // Create a container that will hold the cells. var tilesParent = new GameObject("Container"); tilesParent.transform.parent = transform; tilesParent.transform.localPosition = Vector3.zero; tilesParent.transform.localRotation = Quaternion.identity; m_Tiles = new PlacementTile[dimensions.x, dimensions.y]; for (int y = 0; y < dimensions.y; y++) { for (int x = 0; x < dimensions.x; x++) { Vector3 targetPos = GridToWorld(new IntVector2(x, y), new IntVector2(1, 1)); targetPos.y += 0.01f; PlacementTile newTile = Instantiate(tileToUse); newTile.transform.parent = tilesParent.transform; newTile.transform.position = targetPos; newTile.transform.localRotation = Quaternion.identity; m_Tiles[x, y] = newTile; newTile.SetState(PlacementTileState.Empty); } } } }
/// <summary> /// Set up visualisation tile /// </summary> protected void Awake() { PlacementTile tileToUse; tileToUse = placementTilePrefab; if (tileToUse != null) { m_SpawnedTile = Instantiate(tileToUse); m_SpawnedTile.transform.SetParent(transform); m_SpawnedTile.transform.localPosition = new Vector3(0f, 0.05f, 0f); } }