Tile Map. More...
Inherits tk2dRuntime.ISpriteCollectionForceBuild.
Public Member Functions | |
void | Build () |
Builds the tilemap. Call this after using the SetTile functions to rebuild the affected partitions. Build only rebuilds affected partitions and is efficent enough to use at runtime if you don't use Unity colliders. Avoid building tilemaps every frame if you use Unity colliders as it will likely be too slow for runtime use. | |
void | ForceBuild () |
Like T:Build above, but forces a build of all partitions. | |
bool | GetTileAtPosition (Vector3 position, out int x, out int y) |
Gets the tile coordinate at position. This can be used to obtain tile or color data explicitly from layers Returns true if the position is within the tilemap bounds. | |
bool | GetTileFracAtPosition (Vector3 position, out float x, out float y) |
Gets the tile coordinate at position. This can be used to obtain tile or color data explicitly from layers The fractional value returned is the fraction into the current tile Returns true if the position is within the tilemap bounds. | |
Vector3 | GetTilePosition (int x, int y) |
Returns the tile position in world space. | |
int | GetTileIdAtPosition (Vector3 position, int layer) |
Gets the tile at position. This can be used to obtain tile data, etc -1 = no data or empty tile. | |
tk2dRuntime.TileMap.TileInfo | GetTileInfoForTileId (int tileId) |
Returns the tile info chunk for the tile. Use this to store additional metadata. | |
Color | GetInterpolatedColorAtPosition (Vector3 position) |
Gets the tile at position. This can be used to obtain tile data, etc -1 = no data or empty tile. | |
int | GetTile (int x, int y, int layer) |
Gets the tile on a layer at x, y. | |
tk2dTileFlags | GetTileFlags (int x, int y, int layer) |
Gets the tile flags on a layer at x, y. | |
void | SetTile (int x, int y, int layer, int tile) |
Sets the tile on a layer at x, y - either a sprite Id or -1 if the tile is empty. | |
void | SetTileFlags (int x, int y, int layer, tk2dTileFlags flags) |
Sets the tile flags on a layer at x, y - a combination of tk2dTileFlags. | |
void | ClearTile (int x, int y, int layer) |
Clears the tile on a layer at x, y. | |
Public Attributes | |
string | editorDataGUID = "" |
This is a link to the editor data object (tk2dTileMapEditorData). It contains presets, and other data which isn't really relevant in game. | |
tk2dTileMapData | data |
Tile map data, stores shared parameters for tilemaps. | |
GameObject | renderData |
Tile map render and collider object. | |
int | width = 128 |
Width of the tilemap. | |
int | height = 128 |
Height of the tilemap. | |
int | partitionSizeX = 32 |
X axis partition size for this tilemap. | |
int | partitionSizeY = 32 |
Y axis partition size for this tilemap. | |
Properties | |
Layer[] | Layers [get, set] |
Gets or sets the layers. | |
ColorChannel | ColorChannel [get, set] |
Gets or sets the color channel. | |
GameObject | PrefabsRoot [get, set] |
Gets or sets the prefabs root. |
Tile Map.
void tk2dTileMap.Build | ( | ) |
Builds the tilemap. Call this after using the SetTile functions to rebuild the affected partitions. Build only rebuilds affected partitions and is efficent enough to use at runtime if you don't use Unity colliders. Avoid building tilemaps every frame if you use Unity colliders as it will likely be too slow for runtime use.
void tk2dTileMap.ClearTile | ( | int | x, |
int | y, | ||
int | layer | ||
) |
Clears the tile on a layer at x, y.
void tk2dTileMap.ForceBuild | ( | ) |
Like T:Build above, but forces a build of all partitions.
Color tk2dTileMap.GetInterpolatedColorAtPosition | ( | Vector3 | position | ) |
Gets the tile at position. This can be used to obtain tile data, etc -1 = no data or empty tile.
int tk2dTileMap.GetTile | ( | int | x, |
int | y, | ||
int | layer | ||
) |
Gets the tile on a layer at x, y.
bool tk2dTileMap.GetTileAtPosition | ( | Vector3 | position, |
out int | x, | ||
out int | y | ||
) |
Gets the tile coordinate at position. This can be used to obtain tile or color data explicitly from layers Returns true if the position is within the tilemap bounds.
tk2dTileFlags tk2dTileMap.GetTileFlags | ( | int | x, |
int | y, | ||
int | layer | ||
) |
Gets the tile flags on a layer at x, y.
bool tk2dTileMap.GetTileFracAtPosition | ( | Vector3 | position, |
out float | x, | ||
out float | y | ||
) |
Gets the tile coordinate at position. This can be used to obtain tile or color data explicitly from layers The fractional value returned is the fraction into the current tile Returns true if the position is within the tilemap bounds.
int tk2dTileMap.GetTileIdAtPosition | ( | Vector3 | position, |
int | layer | ||
) |
Gets the tile at position. This can be used to obtain tile data, etc -1 = no data or empty tile.
tk2dRuntime.TileMap.TileInfo tk2dTileMap.GetTileInfoForTileId | ( | int | tileId | ) |
Returns the tile info chunk for the tile. Use this to store additional metadata.
Vector3 tk2dTileMap.GetTilePosition | ( | int | x, |
int | y | ||
) |
Returns the tile position in world space.
void tk2dTileMap.SetTile | ( | int | x, |
int | y, | ||
int | layer, | ||
int | tile | ||
) |
Sets the tile on a layer at x, y - either a sprite Id or -1 if the tile is empty.
void tk2dTileMap.SetTileFlags | ( | int | x, |
int | y, | ||
int | layer, | ||
tk2dTileFlags | flags | ||
) |
Sets the tile flags on a layer at x, y - a combination of tk2dTileFlags.
tk2dTileMapData tk2dTileMap.data |
Tile map data, stores shared parameters for tilemaps.
string tk2dTileMap.editorDataGUID = "" |
This is a link to the editor data object (tk2dTileMapEditorData). It contains presets, and other data which isn't really relevant in game.
int tk2dTileMap.height = 128 |
Height of the tilemap.
int tk2dTileMap.partitionSizeX = 32 |
X axis partition size for this tilemap.
int tk2dTileMap.partitionSizeY = 32 |
Y axis partition size for this tilemap.
GameObject tk2dTileMap.renderData |
Tile map render and collider object.
int tk2dTileMap.width = 128 |
Width of the tilemap.
ColorChannel tk2dTileMap.ColorChannel [get, set] |
Gets or sets the color channel.
Layer [] tk2dTileMap.Layers [get, set] |
Gets or sets the layers.
GameObject tk2dTileMap.PrefabsRoot [get, set] |
Gets or sets the prefabs root.