Question by
mindcrank · Apr 04, 2018 at 10:29 PM ·
tilemaptransparencytilealpha-channel
How can I change the alpha of a Tile Sprite
I have a 2d tilemap full of tree sprites, which is layered over a tilemap of ground tiles. I want to change the transparency of the tile at a given position on the map.
I have a Vector3 position that I need to use to find a tile on the tilemap, and then I need to change the transparency of that tile.
Thankyou in advance for your help!
Comment
Best Answer
Answer by mindcrank · Apr 05, 2018 at 10:17 PM
I figured it out!
tilemap = this.GetComponentInParent(); //find the tile at the pivot tilepos = tilemap.layoutGrid.WorldToCell(position); //set the tile to transparent Color color = new Color(1.0f, 1.0f, 1.0f, 0.5f); tilemap.SetColor(tilepos, color);
Answer by korbend · Oct 29, 2020 at 02:18 PM
In my case you need also change tileflag:
// Flag the tile, inidicating that it can change colour.
// By default it's set to "Lock Colour".
tilemap.SetTileFlags(position, TileFlags.None);