Understanding TileData


When you modify an STETilemap by script, you use the methods SetTileData and GetTileData. They take a parameter called tileData that is an unsigned integer (uint).

This unsigned integer is a raw data representation of a tilemap cell.

The data is divided into attributes, each using different bits of the 32-bit unsigned integer:

  • TileId [16 bits, 0–15]: the id of the tile used to draw this cell.
  • BrushId [12 bits, 16–27]: used to update the tileId when the tilemap mesh is updated.
  • Flags [4 bits: 28, 29, 30, 31]:
    • Updated flag [bit 28]: informs the brush and other subsystems when the cell has been updated. For example, in a random brush it avoids changing the tileId again after this flag is set the first time.
    • Rotate 90º [bit 29]: the cell tile is rotated 90º.
    • Vertical Flip [bit 30]: the cell tile is flipped vertically.
    • Horizontal Flip [bit 31]: the cell tile is flipped horizontally.
[ HFlip:bit31 | VFlip:bit30 | Rot90:bit29 | Updated:bit28 | BrushId:bit27-16 | TileId:bit15-0 ]

For examples of managing tile data, see Set and Get Tile data in an STETilemap from script.