I've been trying to implement GetTileData but to no avail. I need the information on the Tile Data to update itself once the game is at runtime. For example I want the sprite in editor to be X, but during play mode to be Y or when in editor, i want all tiles to have their normal transform, but once play mode is up, i want the Z position to change accordingly. If i do a tilemap.RefreshAllTiles, it goes through every single one of them, but it visually doesn't update as if either the new tile data gets rejected. but this issue only applies to tiles that have been set up in editor. any new tile added during playmode/runtime, works as intended. Example Code (CSharp): [CreateAssetMenu] public class VisualTile : Tile { public Color playmode; public override void GetTileData(Vector3Int position, ITilemap tilemap, ref TileData tileData) { base.GetTileData(position, tilemap, ref tileData); // ANY CHANGE IN TILE DATA if (Application.isPlaying) { // ANY CHANGE IN TILE DATA DURING PLAY tileData.color = playmode; } } } Things I've noticed: - Even in editor mode, two different tile using the same tile from the pallete will always be the same regardles. - Any tile that is added through SetTile will properly show differences. - Any tile that is added from Editor's tilemap brush when the game isn't playing seems to have this issue. - Doing Tilemap.RefreshAllTiles() triggers the code, but does not actually fix the issue. I'll be testing this more over the coming days, but i've been really blocked by this issue which doesn't seem to be documented anywhere.
You aren't doing anything in GetTileData... At least not from what you posted....it's simply calling the base method. If you want the Sprite to change, you need to actually assign it. Ex. https://docs.unity3d.com/ScriptReference/Tilemaps.TileBase.GetTileData.html
Does this simple test case work? Code (CSharp): [CreateAssetMenu] public class VisualTile : Tile { public Sprite editorSprite; public Sprite playSprite; public override void GetTileData(Vector3Int position, ITilemap tilemap, ref TileData tileData) { tileData.sprite = Application.isPlaying ? playSprite : editorSprite; } } Depending on the type of changes you're making, TileFlags may be relevant. You might want to double-check TileFlags. If you're making changes without the correct TileFlags that can sometimes be a source of issues. You should probably describe what you want to do here in more detail / show code.
Apologies, I had mistakenly posted an older copy of it. I'll edit the original post and post it here again Code (CSharp): [CreateAssetMenu] public class VisualTile : Tile { public Color playmode; public override void GetTileData(Vector3Int position, ITilemap tilemap, ref TileData tileData) { base.GetTileData(position, tilemap, ref tileData); // ANY CHANGE IN TILE DATA if (Application.isPlaying) { // ANY CHANGE IN TILE DATA DURING PLAY tileData.color = playmode; } } } From what i found out so far, is that if i paint using a brush for a tile from a pallete, it'll always appear as the pallete, regardless of what changes i have set up in the getTileData But if i programmatically add a tile to the tilemap, it'll appropriately update. Like mentioned above, i've tested the simple case like the above written code, and it did not work. not calling the base tile data ends up causing the tile to be invisible for some reason. tile data gets assigned the editor color, and then gets assigned playmode after, and like mentioned previously, it doesn't work on tiles that have been there in the map pallete but works for tiles that got added at runtime
Try calling Tilemap.RefreshAllTiles during Start. I have a feeling that if you've already painted them into the scene, GetTileData would be called prior to runtime. In other words, if they are already in the scene, there isn't any reason for a call to be made to get tile data.
You likely need to add TileFlags in your TileData (https://docs.unity3d.com/ScriptReference/Tilemaps.TileFlags.html), specifically TileFlags.LockColor or TileFlags.LockTransform. This will lock the color or the transform of each tile in the Tilemap to the values specified by GetTileData. Otherwise, it will retain any values previously set on the Tilemap, usually from previous Tiles.
sorry for being late on the reply, it seems that yes, the issue was the misuse of tiles. It seems that i misunderstood what these flags meant. So i decided to make a new fresh project to test it out. Color red is the target color they should turn to. While i was locking them last time i tried this, it seems i wasn't double checking to make sure that the tile saved itself properly. Lock transform now also works properly as well. Thank you @ChuanXin and @Lo-renzo