Understanding TileData

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

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

This data is divided in different attributes, each of one using different bits of the unsigned integer of 32bits:

  • TileId [16bits, from 0 to 15]: this is the id of the tile used to draw this cell.
  • BrushId [12bits, from 16 to 27]: this is used to update the tileId when the tilemap mesh is updated
  • Flags [4bits, 28, 29, 30 and 31]:
    • Updated flag [bit 28]: used to inform the brush and other subsystem when the cell has been updated. For example, in a random brush, it will avoid 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]

You can see some examples managing a tile data in the tutorial: Set and Get Tile data in an STETilemap

Advertisement

Published by

creativespore

I love making tools for games. And games...

One thought on “Understanding TileData”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s