Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


Tilemap

The Tilemap stores Sprite s in a layout marked by a Grid component.
Read time 13 minutesLast updated 2 days ago

Definition

[RequireComponent(typeof(Transform))]public sealed class Tilemap : GridLayout

Properties

Property

Description

animationFrameRateThe frame rate for all Tile animations in the Tilemap.
cellBoundsReturns the boundaries of the Tilemap in cell size.
colorThe color of the Tilemap layer.
editorPreviewOriginThe origin of the Tilemap in cell position inclusive of editor preview Tiles.
editorPreviewSizeThe size of the Tilemap in cells inclusive of editor preview Tiles.
layoutGridGets the Grid associated with this Tilemap.
localBoundsReturns the boundaries of the Tilemap in local space size.
orientationOrientation of the Tiles in the Tilemap.
orientationMatrixOrientation Matrix of the orientation of the Tiles in the Tilemap.
originThe origin of the Tilemap in cell position.
sizeThe size of the Tilemap in cells.
tileAnchorGets the anchor point of Tiles in the Tilemap.

Methods

Method

Description

AddTileAnimationFlagsAdds the TileAnimationFlags onto the Tile at the given position.
AddTileFlagsAdds the TileFlags onto the Tile at the given position.
BoxFillDoes a box fill with the given Tile on the Tilemap. Starts from given coordinates and fills the limits from start to end (inclusive).
ClearAllEditorPreviewTilesClears all editor preview Tiles that are placed in the Tilemap.
ClearAllTilesClears all Tiles that are placed in the Tilemap.
CompressBoundsCompresses the _origin and _size of the Tilemap to bounds where Tiles exist.
ContainsTileReturns true if the Tilemap contains the given Tile. Returns false if not.
DeleteCellsRemoves cells from within the Tilemap's bounds.
EditorPreviewBoxFillDoes an editor preview of a box fill with the given Tile on the Tilemap. Starts from given coordinates and fills the limits from start to end (inclusive).
EditorPreviewFloodFillDoes an editor preview of a flood fill with the given Tile to place. on the Tilemap starting from the given coordinates.
FloodFillDoes a flood fill with the given Tile to place. on the Tilemap starting from the given coordinates.
GetAnimationFrameRetrieves the current animation frame for a Tile at the given position.
GetAnimationFrameCountRetrieves the number of animation frames for a Tile at the given position.
GetAnimationTimeRetrieves the current running animation time for a Tile at the given position.
GetCellCenterLocalGets the logical center coordinate of a Grid cell in local space. The logical center for a cell of the Tilemap is defined by the Tile Anchor of the Tilemap.
GetCellCenterWorldGets the logical center coordinate of a Grid cell in world space. The logical center for a cell of the Tilemap is defined by the Tile Anchor of the Tilemap.
GetColliderTypeGets the Collider type of a Tile given the XYZ coordinates of a cell in the Tilemap.
GetColorGets the Color of a Tile given the XYZ coordinates of a cell in the Tilemap.
GetEditorPreviewColorGets the Color of an editor preview Tile given the XYZ coordinates of a cell in the Tilemap.
GetEditorPreviewSpriteGets the Sprite used in an editor preview Tile given the XYZ coordinates of a cell in the Tilemap.
GetEditorPreviewTileGets the editor preview Tile at the given XYZ coordinates of a cell in the Tilemap.
GetEditorPreviewTileEntityIdGets the EntityId of the editor preview Tile at the given xyz coordinates of a cell in the Tilemap.
GetEditorPreviewTileFlagsGets the TileFlags of the editor preview Tile at the given position.
GetEditorPreviewTransformMatrixGets the transform matrix of an editor preview Tile given the XYZ coordinates of a cell in the Tilemap.
GetInstantiatedObjectGets the GameObject instantiated by a Tile given the XYZ coordinates of a cell in the Tilemap.
GetObjectToInstantiateGets the GameObject which will be instantiated by a Tile given the XYZ coordinates of a cell in the Tilemap.
GetSpriteGets the Sprite used in a Tile given the XYZ coordinates of a cell in the Tilemap.
GetTileGets the Tile at the given XYZ coordinates of a cell in the Tilemap.
GetTileAnimationFlagsGets the TileAnimationFlags of the Tile at the given position.
GetTileEntityIdGets the EntityId of the Tile at the given xyz coordinates of a cell in the Tilemap.
GetTileEntityIdsFromBlockOffsetGets a block of EntityIds at an offset from the
position
and stores them into the given array of EntityIds in the same order.
GetTileEntityIdsFromOffsetsGets an array of EntityIds at an offset from the
position
and stores them into the given array of EntityIds in the same order.
GetTileFlagsGets the TileFlags of the Tile at the given position.
GetTilesRetrieves all tiles within the given bounds as a Tilemap.TileArray.
GetTilesBlockRetrieves an array of Tiles with the given bounds.
GetTilesBlockNonAllocRetrieves an array of Tiles with the given bounds.
GetTilesRangeCountRetrieves the number of Tiles within the given range, inclusive of the Cells at both the starting position and the ending positions. This method begins at the given starting position and iterates through all available Z Positions, then iterates through the X and Y positions until it reaches the ending position.
GetTilesRangeNonAllocRetrieves an array of Tiles within the given range, inclusive of the Cells at both the starting position and the ending positions. This method begins at the given starting position and iterates through all available Z Positions, then iterates through the X and Y positions until it reaches the ending position.
GetTransformMatrixGets the transform matrix of a Tile given the XYZ coordinates of a cell in the Tilemap.
GetUsedSpritesReturns a Tilemap.SpriteArray containing the unique Sprite instances used in the Tilemap. The array is allocated using the given Allocator.
GetUsedSpritesCountGets the total number of different Sprites used in the Tilemap.
GetUsedSpritesNonAllocFills the given array with the total number of different Sprites used in the Tilemap and returns the number of Sprites filled.
GetUsedTilesReturns a Tilemap.TileArray containing the unique Tile instances used in this Tilemap. The array is allocated using the given Allocator.
GetUsedTilesCountGets the total number of different Tiles used in the Tilemap.
GetUsedTilesNonAllocFills the given array with the total number of different Tiles used in the Tilemap and returns the number of Tiles filled.
HasEditorPreviewTileReturns whether there is an editor preview Tile at the position.
HasTileReturns whether there is a Tile at the position.
InsertCellsInserts cells into the Tilemap.
RefreshAllTilesRefreshes all Tiles in the Tilemap. The Tilemap will retrieve the rendering data, animation data and other data for all tiles and update all relevant components.
RefreshTileRefreshes a Tile at the given XYZ coordinates of a cell in the Tilemap.
RemoveTileAnimationFlagsRemoves the TileAnimationFlags from the Tile at the given position.
RemoveTileFlagsRemoves the TileFlags from the Tile at the given position.
ResizeBoundsResizes Tiles in the Tilemap to bounds defined by _origin and _size.
SetAnimationFrameSets the current animation frame for a Tile at the given position.
SetAnimationTimeSets the running animation time for a Tile at the given position.
SetColliderTypeSets the Collider type of a Tile given the XYZ coordinates of a cell in the Tilemap.
SetColorSets the color of a Tile given the XYZ coordinates of a cell in the Tilemap.
SetEditorPreviewColorSets the color of an editor preview Tile given the XYZ coordinates of a cell in the Tilemap.
SetEditorPreviewTileSets an editor preview Tile given the XYZ coordinates of a cell in the Tilemap.
SetEditorPreviewTransformMatrixSets the transform matrix of an editor preview Tile given the XYZ coordinates of a cell in the Tilemap.
SetTileSets a Tile with additional properties at the given XYZ coordinates of a cell in the Tilemap.
SetTileAnimationFlagsSets the TileAnimationFlags onto the Tile at the given position.
SetTileFlagsSets the TileFlags onto the Tile at the given position.
SetTilesSets an array of Tiles at the given XYZ coordinates of the corresponding cells in the Tilemap.
SetTilesBlockFills an area with array of Tiles.
SetTransformMatrixSets the transform matrix of a Tile given the XYZ coordinates of a cell in the Tilemap.
SwapTileSwaps all existing Tiles of changeTile to newTile and refreshes all the swapped Tiles.

Static Events

Member

Description

loopEndedForTileAnimationCallback when Tiles on a Tilemap have reached the end of their loop for their Tile Animation.
tilemapPositionsChangedCallback when Tiles on a Tilemap have changed.
tilemapTileChangedCallback when Tiles on a Tilemap have changed.

Structs

Struct

Description

Tilemap.PositionArrayA read-only array containing Tilemap positions.
Tilemap.SpriteArrayA read-only array containing Sprite EntityIds.
Tilemap.SyncTileA Struct for containing changes to a Tile when it has been changed on a Tilemap.
Tilemap.TileArrayA read-only array containing Tile EntityIds.

Enums

Enum

Description

Tilemap.OrientationDetermines the orientation of Tiles in the Tilemap.

Inheritance

Inherited Members

Operators

Operator

Description

operator ==Compares two object references to see if they refer to the same object.
boolDetermines whether the object exists.
operator !=Compares if two objects refer to a different object.