private void Awake() { tileInstances = new List <BuildableTile>(width * depth); Vector3 startingPosition = transform.position; startingPosition.x -= width / 2.0f; startingPosition.z -= depth / 2.0f; for (int x = 0; x < width; x++) { for (int y = 0; y < depth; y++) { Vector3 tilePosition = new Vector3(x + 0.5f, 0, y + 0.5f); BuildableTile instance = Instantiate( buildableTilePrefab, startingPosition + tilePosition, Quaternion.identity, transform ); tileInstances.Add(instance); // NetworkServer.Spawn(instance.gameObject); } } }
private void Start() { BuildableGrid[] grids = GetComponentsInChildren <BuildableGrid>(); int tileId = 0; for (int i = 0; i < grids.Length; i++) { List <BuildableTile> tilesInGrid = grids[i].GetTiles(); for (int j = 0; j < tilesInGrid.Count; j++) { BuildableTile tile = tilesInGrid[j]; tileIdToTiles[tileId] = tile; tile.SetTileId(tileId); tileId++; } } }