public void SetColumnCount(int newWidth, bool manageData) { int change = newWidth - Width; if (change == 0) { return; } if (newWidth < 1) { return; } Tile[] newItems = new Tile[newWidth * Height]; int copyCount = Mathf.Min(newWidth, Width); if (manageData) { // Copy valid tiles for (int x = 0; x < copyCount; x++) { for (int y = 0; y < Height; y++) { newItems[newWidth * y + x] = GetTile(x, y); } } // Remove old tiles for (int x = copyCount; x < Width; x++) { for (int y = 0; y < Height; y++) { Owner.DestroyTile(x, y); } } } _Tiles = newItems; Width = newWidth; if (manageData) { // Add new tiles for (int x = copyCount; x < Width; x++) { for (int y = 0; y < Height; y++) { Owner.CreateTile(new Vector2Int(x, y)); } } } }