#Tilemap functions not working with hexagon tilemaps

4 messages · Page 1 of 1 (latest)

lapis spear
#
    void Start()
    {
        BoundsInt bounds = tileMap.cellBounds;
        TileBase[] allTiles = tileMap.GetTilesBlock(bounds);

        for (int x = 0; x < bounds.size.x; x++)
        {
            for (int y = 0; y < bounds.size.y; y++)
            {
                TileBase tile = allTiles[x + y * bounds.size.x];
                if (tile != null)
                {
                    GameObject obj = new("Tile");
                    obj.transform.parent = TileParent.transform;
                    var newTile = new CustomTile(tileMap.CellToWorld(new Vector3Int(x,y)), obj, Hexagon);
                    Tiles.Add(newTile);
                }
            }
        }
        foreach (var tile in Tiles)
        {
            print(tile.gameObject.transform.position);
        }
    }```
#

this code is supposed to map the white tiles and put an image over them but it isnt wroking

#

ok so i found a solution