Version: 2017.3 (switch to 2017.4)
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

Tilemap

class in UnityEngine.Tilemaps

/

Inherits from:GridLayout

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 tile map stores sprites in a layout marked by a Grid component.

Properties

animationFrameRateThe frame rate for all tile animations in the tile map.
cellBoundsReturns the boundaries of the Tilemap in cell size.
colorThe color of the tile map 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 tile map.
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 tile map. 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.
EditorPreviewBoxFillDoes an editor preview of a box fill with the given tile on the tile map. 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 tile map starting from the given coordinates.
FloodFillDoes a flood fill with the given tile to place. on the tile map starting from the given coordinates.
GetCellCenterLocalGet the logical center coordinate of a grid cell in local space.
GetCellCenterWorldGet the logical center coordinate of a grid cell in world space.
GetColliderTypeGets the collider type of a tile given the XYZ coordinates of a cell in the tile map.
GetColorGets the color of a tile given the XYZ coordinates of a cell in the tile map.
GetEditorPreviewColorGets the Color of an editor preview tile given the XYZ coordinates of a cell in the tile map.
GetEditorPreviewSpriteGets the Sprite used in an editor preview tile given the XYZ coordinates of a cell in the tile map.
GetEditorPreviewTileGets the editor preview tile at the given XYZ coordinates of a cell in the tile map.
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 tile map.
GetInstantiatedObjectGets the GameObject instantiated by a tile given the XYZ coordinates of a cell in the tile map.
GetSpriteGets the Sprite used in a tile given the XYZ coordinates of a cell in the tile map.
GetTileGets the tile at the given XYZ coordinates of a cell in the tile map.
GetTileFlagsGets the TileFlags of the Tile at the given position.
GetTilesBlockRetrieves an array of tiles with the given bounds.
GetTransformMatrixGets the transform matrix of a tile given the XYZ coordinates of a cell in the tile map.
GetUsedTilesCountGet 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.
RefreshAllTilesRefreshes all tiles in the tile map. The tile map will retrieve the rendering data, animation data and other data for all tiles and update all relevant components.
RefreshTileRefreshes a tile at the given coordinates of a cell in the tile map.
RemoveTileFlagsRemoves the TileFlags onto the Tile at the given position.
ResizeBoundsResizes tiles in the Tilemap to bounds defined by origin and size.
SetColliderTypeSets the collider type of a tile given the XYZ coordinates of a cell in the tile map.
SetColorSets the color of a tile given the XYZ coordinates of a cell in the tile map.
SetEditorPreviewColorSets the color of an editor preview tile given the XYZ coordinates of a cell in the tile map.
SetEditorPreviewTileSets an editor preview tile given the XYZ coordinates of a cell in the tile map.
SetEditorPreviewTransformMatrixSets the transform matrix of an editor preview tile given the XYZ coordinates of a cell in the tile map.
SetTileSets a tile at the given XYZ coordinates of a cell in the tile map.
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 tile map.
SetTilesBlockFills bounds with array of tiles.
SetTransformMatrixSets the transform matrix of a tile given the XYZ coordinates of a cell in the tile map.
SwapTileSwaps all existing tiles of changeTile to newTile and refreshes all the swapped tiles.

Inherited Members

Properties

enabledEnabled Behaviours are Updated, disabled Behaviours are not.
isActiveAndEnabledHas the Behaviour had enabled called.
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.
CompareTagIs this game object tagged with tag ?
GetComponentReturns the component of Type type if the game object has one attached, null if it doesn't.
GetComponentInChildrenReturns the component of Type type in the GameObject or any of its children using depth first search.
GetComponentInParentReturns the component of Type 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.
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.
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.
GetInstanceIDReturns the instance id of the object.
ToStringReturns the name of the GameObject.

Static Methods

DestroyRemoves a gameobject, component or asset.
DestroyImmediateDestroys the object obj immediately. You are strongly recommended to use Destroy instead.
DontDestroyOnLoadMakes the object target not be destroyed automatically when loading a new scene.
FindObjectOfTypeReturns the first active loaded object of Type type.
FindObjectsOfTypeReturns a list of all active 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.
对文档有任何疑问,请移步至开发者社区提问,我们将尽快为您解答