Version: 2022.1
LanguageEnglish
  • C#

Tilemap

class in UnityEngine.Tilemaps

/

Inherits from:GridLayout

/

Implemented in:UnityEngine.TilemapModule

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Description

The Tilemap stores Sprites in a layout marked by a Grid component.

Properties

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.

Public Methods

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.
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.
GetTileFlagsGets the TileFlags of the Tile at the given position.
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.
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.
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.
RemoveTileFlagsRemoves the TileFlags onto 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 at the given XYZ coordinates of a cell in the Tilemap.
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 bounds 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.

Events

tilemapPositionsChangedCallback when Tiles on a Tilemap have changed.
tilemapTileChangedCallback when Tiles on a Tilemap have changed.

Inherited Members

Properties

enabledEnabled Behaviours are Updated, disabled Behaviours are not.
isActiveAndEnabledReports whether a GameObject and its associated Behaviour is active and enabled.
gameObjectThe game object this component is attached to. A component is always attached to a game object.
tagThe tag of this game object.
transformThe Transform attached to this GameObject.
cellGapThe size of the gap between each cell in the layout.
cellLayoutThe layout of the cells.
cellSizeThe size of each cell in the layout.
cellSwizzleThe cell swizzle for the layout.
hideFlagsShould the object be hidden, saved with the Scene or modifiable by the user?
nameThe name of the object.

Public Methods

BroadcastMessageCalls the method named methodName on every MonoBehaviour in this game object or any of its children.
CompareTagChecks the GameObject's tag against the defined tag.
GetComponentReturns the component of type if the GameObject has one attached.
GetComponentInChildrenReturns the Component of type in the GameObject or any of its children using depth first search.
GetComponentInParentReturns the Component of type in the GameObject or any of its parents.
GetComponentsReturns all components of Type type in the GameObject.
GetComponentsInChildrenReturns all components of Type type in the GameObject or any of its children. Works recursively.
GetComponentsInParentReturns all components of Type type in the GameObject or any of its parents.
SendMessageCalls the method named methodName on every MonoBehaviour in this game object.
SendMessageUpwardsCalls the method named methodName on every MonoBehaviour in this game object and on every ancestor of the behaviour.
TryGetComponentGets the component of the specified type, if it exists.
CellToLocalConverts a cell position to local position space.
CellToLocalInterpolatedConverts an interpolated cell position in floats to local position space.
CellToWorldConverts a cell position to world position space.
GetBoundsLocalReturns the local bounds for a cell at the location.
GetLayoutCellCenterGet the default center coordinate of a cell for the set layout of the Grid.
LocalToCellConverts a local position to cell position.
LocalToCellInterpolatedConverts a local position to cell position.
LocalToWorldConverts a local position to world position.
WorldToCellConverts a world position to cell position.
WorldToLocalConverts a world position to local position.
GetInstanceIDGets the instance ID of the object.
ToStringReturns the name of the object.

Static Methods

DestroyRemoves a GameObject, component or asset.
DestroyImmediateDestroys the object obj immediately. You are strongly recommended to use Destroy instead.
DontDestroyOnLoadDo not destroy the target Object when loading a new Scene.
FindObjectOfTypeReturns the first active loaded object of Type type.
FindObjectsOfTypeGets a list of all loaded objects of Type type.
InstantiateClones the object original and returns the clone.

Operators

boolDoes the object exist?
operator !=Compares if two objects refer to a different object.
operator ==Compares two object references to see if they refer to the same object.