I’ve found very little information about this, but when I call the function
“Tilemap.SetEditorPreviewColor” on my preview-tile it doesn’t change the color of it.
Has anyone else had this problem? If so how did you fix it?
I’m setting the preview-tile (which is working) like below, however the color-changing-call seems to do nothing:
public Tilemap groundTilemap;
public TileBase prevTile;
//rest of code...
//Inside function, trying to set a preview tile and then color it RED below
groundTilemap.SetEditorPreviewTile(getPositiong(), prevTile);
groundTilemap.SetEditorPreviewColor(getPositiong(), new Color(1, 0, 0));
In the link they seem to discuss colors of regular tiles however, and that I have no problem changing the color of! Changing regular tile-colors for me works just as intended (using the function Tilemap.SetColor())
What I’m having trouble with is the “preview-tiles” which have their own set of functions. So I can color my regular tiles fine but preview-tiles don’t work with color-changes (despite using the assigned function). That is the odd part.
If you know of any resources regarding problems with “preview-tile”-color changes I’d love to see them!
Setting the color of an Editor Preview Tile follows the same rules as a normal Tile. Ensure that the Tile Flags of the Editor Preview Tile do not have LockColor on when setting the Editor Preview Color. The Editor Preview Color only works if there is an Editor Preview Tile set, and will not change the color of a set Tile.
Oh, I see. I didn’t add any flags to my Preview Tiles, are they perhaps by default set to LockColor? I will try to inactivate this flag if so!
Finding this information (that preview-tiles must not have flags that are set to “LockColor” for it to work) was a little tricky. Perhaps if it’s possible/appropriate it would be nice if it was somehow included in the documentation for the function in some form? (for eg. here: https://docs.unity3d.com/ScriptReference/Tilemaps.Tilemap.SetEditorPreviewColor.html)
Just for the next person who might be stumped by this/have the same issue.