Version: 2022.1

Tilemap

class in UnityEngine.Tilemaps

/

继承自:GridLayout

切换到手册

描述

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

变量

animationFrameRateThe frame rate for all Tile animations in the Tilemap.
cellBounds以单元格大小返回 Tilemap 的边界。
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.
localBounds以本地空间大小返回 Tilemap 的边界。
orientationOrientation of the Tiles in the Tilemap.
orientationMatrixOrientation Matrix of the orientation of the Tiles in the Tilemap.
origin Tilemap 的原点(以单元格位置为单位)。
size Tilemap 的大小(以单元格为单位)。
tileAnchorGets the anchor point of Tiles in the Tilemap.

公共函数

AddTileFlags将 TileFlags 添加到给定位置处的 Tile。
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.
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 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.
GetEditorPreviewTileFlags获取给定位置处的编辑器预览 Tile 的 TileFlags。
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.
GetTileFlags获取给定位置处的 Tile 的 TileFlags。
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.
RemoveTileFlags删除给定位置处的 Tile 上的 TileFlags。
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.
SetTileFlags将 TileFlags 设置到给定位置处的 Tile 上。
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

tilemapPositionsChanged瓦片地图上的瓦片发生更改时的回调。
tilemapTileChanged瓦片地图上的瓦片发生更改时的回调。

继承的成员

变量

enabled启用的 Behaviour 可更新,禁用的 Behaviour 不可更新。
isActiveAndEnabledReports whether a GameObject and its associated Behaviour is active and enabled.
gameObject此组件附加到的游戏对象。始终将组件附加到游戏对象。
tag此游戏对象的标签。
transform附加到此 GameObject 的 Transform。
cellGap布局中各个单元格之间的间隙大小。
cellLayout单元格的布局。
cellSize布局中每个单元格的大小。
cellSwizzle布局的单元格重排。
hideFlags该对象应该隐藏、随场景一起保存还是由用户修改?
name对象的名称。

公共函数

BroadcastMessage调用此游戏对象或其任何子项中的每个 MonoBehaviour 上名为 methodName 的方法。
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.
GetComponents返回 GameObject 中类型为 type 的所有组件。
GetComponentsInChildrenReturns all components of Type type in the GameObject or any of its children. Works recursively.
GetComponentsInParent返回 GameObject 或其任何父项中类型为 type 的所有组件。
SendMessage调用此游戏对象中的每个 MonoBehaviour 上名为 methodName 的方法。
SendMessageUpwards调用此游戏对象中的每个 MonoBehaviour 上或此行为的每个父级上名为 methodName 的方法。
TryGetComponent获取指定类型的组件(如果存在)。
CellToLocal将单元格位置转换为本地空间位置。
CellToLocalInterpolated将插值单元格位置(浮点数)转换为本地空间位置。
CellToWorld将单元格位置转换为世界空间位置。
GetBoundsLocal返回该位置的单元格的本地边界。
GetLayoutCellCenter获取 Grid 的设置布局的单元格默认中心坐标。
LocalToCell将本地位置转换为单元格位置。
LocalToCellInterpolated将本地位置转换为单元格位置。
LocalToWorld将本地位置转换为世界位置。
WorldToCell将世界位置转换为单元格位置。
WorldToLocal将世界位置转换为本地位置。
GetInstanceIDGets the instance ID of the object.
ToString返回对象的名称。

静态函数

Destroy移除 GameObject、组件或资源。
DestroyImmediate立即销毁对象 /obj/。强烈建议您改用 Destroy。
DontDestroyOnLoad在加载新的 Scene 时,请勿销毁 Object。
FindObjectOfType返回第一个类型为 type 的已加载的激活对象。
FindObjectsOfTypeGets a list of all loaded objects of Type type.
Instantiate克隆 original 对象并返回克隆对象。

运算符

bool该对象是否存在?
operator !=比较两个对象是否引用不同的对象。
operator ==比较两个对象引用,判断它们是否引用同一个对象。