void CreateNewTile() { EnvironmentTile previousTile = null; if (InstancedTiles != null && InstancedTiles.Count > 0) { previousTile = InstancedTiles[InstancedTiles.Count - 1]; } // Create and attach new tile EnvironmentTile newTile = tiles[Random.Range(0, tiles.Count)].GetInstance <EnvironmentTile>(); if (previousTile) { newTile.AttachAt(previousTile, this); } // Add tile to end of list InstancedTiles.Add(newTile); }