- Home /
Get sprite of Tile
How to get sprite of tile at x,y position in tilemap?
I see only one way: TileBase.GetTileData()
, but it requires ITilemap
argument, while i have only Tilemap
. Maybe there's better solution exists?
Tilemap tileMap = gameObj.GetComponent<Tilemap>();
TileBase[] tiles;
BoundsInt bounds = tileMap.cellBounds;
tiles = tileMap.GetTilesBlock(bounds);
TileData td = new TileData();
tiles[0].GetTileData(Vector3Int.zero, new ITilemap ???, ref td); //error here
i can't figure out where you can get the ITilemap that references a tilemap..... but i did a broken hack of the ruletile class from the github.... i basically added a public ITilemap to the class and then have it store the ITilemap that's passed to it in the GetTileData..... but it completely breaks if you have more than one tilemap.
i really wish the documentation would include an example of how you can get the ITilemap to pass to that function....
update: if you're using RuleTiles i was able to change the ITilemap to Tilemap in all of it's RuleCheck functions. and then use tilemap.GetComponent() when the GetTileData function and GetAnimation function call those rule checks... .and then copy the GetTileData function and have it take a regular Tilemap.... it worked for my purposes....
Your answer
Follow this Question
Related Questions
tilepalette problems 0 Answers
Tilemap: Resizing Tiles? 1 Answer
How to use a Sprite Mask on Tilemap Tiles 0 Answers