Hey all,
I’m trying to change the color of select tiles using their X and Y coordinates but everything I’ve tried doesn’t make a difference. I’ve tried removing any flags like ‘LockColor’ from the tiles before trying to use .SetColor() and also tried refreshing the tile aftwards with no success.
Here’s the small function I’m running to test to color changing. ‘tile’ is being populated with Tiles elsewhere before this is called.
public Tilemap worldTilemap;
void ColorTiles()
{
for (int x = 0; x < worldWidth; x += 1)
{
for (int y = 0; y < worldHeight; y += 1)
{
worldTilemap.SetTile(new Vector3Int(x, y, 0), tile[0]);
worldTilemap.SetTileFlags(new Vector3Int(x, y, 0), TileFlags.None);
worldTilemap.SetColor(new Vector3Int(x, y, 0), Color.red);
worldTilemap.RefreshTile(new Vector3Int(x, y, 0));
}
}
}
There were also some similar threads that said about ‘unlocking’ the grid, but I couldn’t find the option so I assumed it had been updated and changed.
Another possibility I could use help with is changing the color of a tile’s resource file. I’m able to manually change the color of the tile via the inspector but I’m not sure how to do it via script.
Thanks.