Class TileSet
- Namespace
- Godot
- Assembly
- GodotSharp.dll
A TileSet is a library of tiles for a TileMap. A TileSet handles a list of TileSetSource, each of them storing a set of tiles.
Tiles can either be from a TileSetAtlasSource, which renders tiles out of a texture with support for physics, navigation, etc., or from a TileSetScenesCollectionSource, which exposes scene-based tiles.
Tiles are referenced by using three IDs: their source ID, their atlas coordinates ID, and their alternative tile ID.
A TileSet can be configured so that its tiles expose more or fewer properties. To do so, the TileSet resources use property layers, which you can add or remove depending on your needs.
For example, adding a physics layer allows giving collision shapes to your tiles. Each layer has dedicated properties (physics layer and mask), so you may add several TileSet physics layers for each type of collision you need.
See the functions to add new layers for more information.
public class TileSet : Resource, IDisposable
- Inheritance
-
TileSet
- Implements
- Inherited Members
Constructors
TileSet()
public TileSet()
Properties
TileLayout
For all half-offset shapes (Isometric, Hexagonal and Half-Offset square), changes the way tiles are indexed in the TileMap grid.
public TileSet.TileLayoutEnum TileLayout { get; set; }
Property Value
TileOffsetAxis
For all half-offset shapes (Isometric, Hexagonal and Half-Offset square), determines the offset axis.
public TileSet.TileOffsetAxisEnum TileOffsetAxis { get; set; }
Property Value
TileShape
The tile shape.
public TileSet.TileShapeEnum TileShape { get; set; }
Property Value
TileSize
The tile size, in pixels. For all tile shapes, this size corresponds to the encompassing rectangle of the tile shape. This is thus the minimal cell size required in an atlas.
public Vector2I TileSize { get; set; }
Property Value
UVClipping
Enables/Disable uv clipping when rendering the tiles.
public bool UVClipping { get; set; }
Property Value
Methods
AddCustomDataLayer(int)
Adds a custom data layer to the TileSet at the given position toPosition
in the array. If toPosition
is -1, adds it at the end of the array.
Custom data layers allow assigning custom properties to atlas tiles.
public void AddCustomDataLayer(int toPosition = -1)
Parameters
toPosition
int
AddNavigationLayer(int)
Adds a navigation layer to the TileSet at the given position toPosition
in the array. If toPosition
is -1, adds it at the end of the array.
Navigation layers allow assigning a navigable area to atlas tiles.
public void AddNavigationLayer(int toPosition = -1)
Parameters
toPosition
int
AddOcclusionLayer(int)
Adds an occlusion layer to the TileSet at the given position toPosition
in the array. If toPosition
is -1, adds it at the end of the array.
Occlusion layers allow assigning occlusion polygons to atlas tiles.
public void AddOcclusionLayer(int toPosition = -1)
Parameters
toPosition
int
AddPattern(TileMapPattern, int)
Adds a TileMapPattern to be stored in the TileSet resource. If provided, insert it at the given index
.
public int AddPattern(TileMapPattern pattern, int index = -1)
Parameters
pattern
TileMapPatternindex
int
Returns
AddPhysicsLayer(int)
Adds a physics layer to the TileSet at the given position toPosition
in the array. If toPosition
is -1, adds it at the end of the array.
Physics layers allow assigning collision polygons to atlas tiles.
public void AddPhysicsLayer(int toPosition = -1)
Parameters
toPosition
int
AddSource(TileSetSource, int)
Adds a TileSetSource to the TileSet. If atlasSourceIdOverride
is not -1, also set its source ID. Otherwise, a unique identifier is automatically generated.
The function returns the added source ID or -1 if the source could not be added.
Warning: A source cannot belong to two TileSets at the same time. If the added source was attached to another TileSet, it will be removed from that one.
public int AddSource(TileSetSource source, int atlasSourceIdOverride = -1)
Parameters
source
TileSetSourceatlasSourceIdOverride
int
Returns
AddTerrain(int, int)
Adds a new terrain to the given terrain set terrainSet
at the given position toPosition
in the array. If toPosition
is -1, adds it at the end of the array.
public void AddTerrain(int terrainSet, int toPosition = -1)
Parameters
AddTerrainSet(int)
Adds a new terrain set at the given position toPosition
in the array. If toPosition
is -1, adds it at the end of the array.
public void AddTerrainSet(int toPosition = -1)
Parameters
toPosition
int
CleanupInvalidTileProxies()
Clears tile proxies pointing to invalid tiles.
public void CleanupInvalidTileProxies()
ClearTileProxies()
Clears all tile proxies.
public void ClearTileProxies()
GetAlternativeLevelTileProxy(int, Vector2I, int)
Returns the alternative-level proxy for the given identifiers. The returned array contains the three proxie's target identifiers (source ID, atlas coords ID and alternative tile ID).
If the TileSet has no proxy for the given identifiers, returns an empty Array.
public Array GetAlternativeLevelTileProxy(int sourceFrom, Vector2I coordsFrom, int alternativeFrom)
Parameters
Returns
GetCoordsLevelTileProxy(int, Vector2I)
Returns the coordinate-level proxy for the given identifiers. The returned array contains the two target identifiers of the proxy (source ID and atlas coordinates ID).
If the TileSet has no proxy for the given identifiers, returns an empty Array.
public Array GetCoordsLevelTileProxy(int sourceFrom, Vector2I coordsFrom)
Parameters
Returns
GetCustomDataLayerByName(string)
Returns the index of the custom data layer identified by the given name.
public int GetCustomDataLayerByName(string layerName)
Parameters
layerName
string
Returns
GetCustomDataLayerName(int)
Returns the name of the custom data layer identified by the given index.
public string GetCustomDataLayerName(int layerIndex)
Parameters
layerIndex
int
Returns
GetCustomDataLayerType(int)
Returns the type of the custom data layer identified by the given index.
public Variant.Type GetCustomDataLayerType(int layerIndex)
Parameters
layerIndex
int
Returns
GetCustomDataLayersCount()
Returns the custom data layers count.
public int GetCustomDataLayersCount()
Returns
GetNavigationLayerLayerValue(int, int)
Returns whether or not the specified navigation layer of the TileSet navigation data layer identified by the given layerIndex
is enabled, given a navigation_layers layerNumber
between 1 and 32.
public bool GetNavigationLayerLayerValue(int layerIndex, int layerNumber)
Parameters
Returns
GetNavigationLayerLayers(int)
Returns the navigation layers (as in the Navigation server) of the given TileSet navigation layer.
public uint GetNavigationLayerLayers(int layerIndex)
Parameters
layerIndex
int
Returns
GetNavigationLayersCount()
Returns the navigation layers count.
public int GetNavigationLayersCount()
Returns
GetNextSourceId()
Returns a new unused source ID. This generated ID is the same that a call to AddSource(TileSetSource, int) would return.
public int GetNextSourceId()
Returns
GetOcclusionLayerLightMask(int)
Returns the light mask of the occlusion layer.
public int GetOcclusionLayerLightMask(int layerIndex)
Parameters
layerIndex
int
Returns
GetOcclusionLayerSdfCollision(int)
Returns if the occluders from this layer use sdf_collision
.
public bool GetOcclusionLayerSdfCollision(int layerIndex)
Parameters
layerIndex
int
Returns
GetOcclusionLayersCount()
Returns the occlusion layers count.
public int GetOcclusionLayersCount()
Returns
GetPattern(int)
Returns the TileMapPattern at the given index
.
public TileMapPattern GetPattern(int index = -1)
Parameters
index
int
Returns
GetPatternsCount()
Returns the number of TileMapPattern this tile set handles.
public int GetPatternsCount()
Returns
GetPhysicsLayerCollisionLayer(int)
Returns the collision layer (as in the physics server) bodies on the given TileSet's physics layer are in.
public uint GetPhysicsLayerCollisionLayer(int layerIndex)
Parameters
layerIndex
int
Returns
GetPhysicsLayerCollisionMask(int)
Returns the collision mask of bodies on the given TileSet's physics layer.
public uint GetPhysicsLayerCollisionMask(int layerIndex)
Parameters
layerIndex
int
Returns
GetPhysicsLayerPhysicsMaterial(int)
Returns the physics material of bodies on the given TileSet's physics layer.
public PhysicsMaterial GetPhysicsLayerPhysicsMaterial(int layerIndex)
Parameters
layerIndex
int
Returns
GetPhysicsLayersCount()
Returns the physics layers count.
public int GetPhysicsLayersCount()
Returns
GetSource(int)
Returns the TileSetSource with ID sourceId
.
public TileSetSource GetSource(int sourceId)
Parameters
sourceId
int
Returns
GetSourceCount()
Returns the number of TileSetSource in this TileSet.
public int GetSourceCount()
Returns
GetSourceId(int)
Returns the source ID for source with index index
.
public int GetSourceId(int index)
Parameters
index
int
Returns
GetSourceLevelTileProxy(int)
Returns the source-level proxy for the given source identifier.
If the TileSet has no proxy for the given identifier, returns -1.
public int GetSourceLevelTileProxy(int sourceFrom)
Parameters
sourceFrom
int
Returns
GetTerrainColor(int, int)
Returns a terrain's color.
public Color GetTerrainColor(int terrainSet, int terrainIndex)
Parameters
Returns
GetTerrainName(int, int)
Returns a terrain's name.
public string GetTerrainName(int terrainSet, int terrainIndex)
Parameters
Returns
GetTerrainSetMode(int)
Returns a terrain set mode.
public TileSet.TerrainMode GetTerrainSetMode(int terrainSet)
Parameters
terrainSet
int
Returns
GetTerrainSetsCount()
Returns the terrain sets count.
public int GetTerrainSetsCount()
Returns
GetTerrainsCount(int)
Returns the number of terrains in the given terrain set.
public int GetTerrainsCount(int terrainSet)
Parameters
terrainSet
int
Returns
HasAlternativeLevelTileProxy(int, Vector2I, int)
Returns if there is an alternative-level proxy for the given identifiers.
public bool HasAlternativeLevelTileProxy(int sourceFrom, Vector2I coordsFrom, int alternativeFrom)
Parameters
Returns
HasCoordsLevelTileProxy(int, Vector2I)
Returns if there is a coodinates-level proxy for the given identifiers.
public bool HasCoordsLevelTileProxy(int sourceFrom, Vector2I coordsFrom)
Parameters
Returns
HasGodotClassMethod(in godot_string_name)
Check if the type contains a method with the given name. This method is used by Godot to check if a method exists before invoking it. Do not call or override this method.
protected override bool HasGodotClassMethod(in godot_string_name method)
Parameters
method
godot_string_nameName of the method to check for.
Returns
HasGodotClassSignal(in godot_string_name)
Check if the type contains a signal with the given name. This method is used by Godot to check if a signal exists before raising it. Do not call or override this method.
protected override bool HasGodotClassSignal(in godot_string_name signal)
Parameters
signal
godot_string_nameName of the signal to check for.
Returns
HasSource(int)
Returns if this TileSet has a source for the given source ID.
public bool HasSource(int sourceId)
Parameters
sourceId
int
Returns
HasSourceLevelTileProxy(int)
Returns if there is a source-level proxy for the given source ID.
public bool HasSourceLevelTileProxy(int sourceFrom)
Parameters
sourceFrom
int
Returns
InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)
Invokes the method with the given name, using the given arguments. This method is used by Godot to invoke methods from the engine side. Do not call or override this method.
protected override bool InvokeGodotClassMethod(in godot_string_name method, NativeVariantPtrArgs args, out godot_variant ret)
Parameters
method
godot_string_nameName of the method to invoke.
args
NativeVariantPtrArgsArguments to use with the invoked method.
ret
godot_variantValue returned by the invoked method.
Returns
MapTileProxy(int, Vector2I, int)
According to the configured proxies, maps the provided identifiers to a new set of identifiers. The source ID, atlas coordinates ID and alternative tile ID are returned as a 3 elements Array.
This function first look for matching alternative-level proxies, then coordinates-level proxies, then source-level proxies.
If no proxy corresponding to provided identifiers are found, returns the same values the ones used as arguments.
public Array MapTileProxy(int sourceFrom, Vector2I coordsFrom, int alternativeFrom)
Parameters
Returns
MoveCustomDataLayer(int, int)
Moves the custom data layer at index layerIndex
to the given position toPosition
in the array. Also updates the atlas tiles accordingly.
public void MoveCustomDataLayer(int layerIndex, int toPosition)
Parameters
MoveNavigationLayer(int, int)
Moves the navigation layer at index layerIndex
to the given position toPosition
in the array. Also updates the atlas tiles accordingly.
public void MoveNavigationLayer(int layerIndex, int toPosition)
Parameters
MoveOcclusionLayer(int, int)
Moves the occlusion layer at index layerIndex
to the given position toPosition
in the array. Also updates the atlas tiles accordingly.
public void MoveOcclusionLayer(int layerIndex, int toPosition)
Parameters
MovePhysicsLayer(int, int)
Moves the physics layer at index layerIndex
to the given position toPosition
in the array. Also updates the atlas tiles accordingly.
public void MovePhysicsLayer(int layerIndex, int toPosition)
Parameters
MoveTerrain(int, int, int)
Moves the terrain at index terrainIndex
for terrain set terrainSet
to the given position toPosition
in the array. Also updates the atlas tiles accordingly.
public void MoveTerrain(int terrainSet, int terrainIndex, int toPosition)
Parameters
MoveTerrainSet(int, int)
Moves the terrain set at index terrainSet
to the given position toPosition
in the array. Also updates the atlas tiles accordingly.
public void MoveTerrainSet(int terrainSet, int toPosition)
Parameters
RemoveAlternativeLevelTileProxy(int, Vector2I, int)
Removes an alternative-level proxy for the given identifiers.
public void RemoveAlternativeLevelTileProxy(int sourceFrom, Vector2I coordsFrom, int alternativeFrom)
Parameters
RemoveCoordsLevelTileProxy(int, Vector2I)
Removes a coordinates-level proxy for the given identifiers.
public void RemoveCoordsLevelTileProxy(int sourceFrom, Vector2I coordsFrom)
Parameters
RemoveCustomDataLayer(int)
Removes the custom data layer at index layerIndex
. Also updates the atlas tiles accordingly.
public void RemoveCustomDataLayer(int layerIndex)
Parameters
layerIndex
int
RemoveNavigationLayer(int)
Removes the navigation layer at index layerIndex
. Also updates the atlas tiles accordingly.
public void RemoveNavigationLayer(int layerIndex)
Parameters
layerIndex
int
RemoveOcclusionLayer(int)
Removes the occlusion layer at index layerIndex
. Also updates the atlas tiles accordingly.
public void RemoveOcclusionLayer(int layerIndex)
Parameters
layerIndex
int
RemovePattern(int)
Remove the TileMapPattern at the given index.
public void RemovePattern(int index)
Parameters
index
int
RemovePhysicsLayer(int)
Removes the physics layer at index layerIndex
. Also updates the atlas tiles accordingly.
public void RemovePhysicsLayer(int layerIndex)
Parameters
layerIndex
int
RemoveSource(int)
Removes the source with the given source ID.
public void RemoveSource(int sourceId)
Parameters
sourceId
int
RemoveSourceLevelTileProxy(int)
Removes a source-level tile proxy.
public void RemoveSourceLevelTileProxy(int sourceFrom)
Parameters
sourceFrom
int
RemoveTerrain(int, int)
Removes the terrain at index terrainIndex
in the given terrain set terrainSet
. Also updates the atlas tiles accordingly.
public void RemoveTerrain(int terrainSet, int terrainIndex)
Parameters
RemoveTerrainSet(int)
Removes the terrain set at index terrainSet
. Also updates the atlas tiles accordingly.
public void RemoveTerrainSet(int terrainSet)
Parameters
terrainSet
int
SetAlternativeLevelTileProxy(int, Vector2I, int, int, Vector2I, int)
Create an alternative-level proxy for the given identifiers. A proxy will map set of tile identifiers to another set of identifiers.
This can be used to replace a tile in all TileMaps using this TileSet, as TileMap nodes will find and use the proxy's target tile when one is available.
Proxied tiles can be automatically replaced in TileMap nodes using the editor.
public void SetAlternativeLevelTileProxy(int sourceFrom, Vector2I coordsFrom, int alternativeFrom, int sourceTo, Vector2I coordsTo, int alternativeTo)
Parameters
sourceFrom
intcoordsFrom
Vector2IalternativeFrom
intsourceTo
intcoordsTo
Vector2IalternativeTo
int
SetCoordsLevelTileProxy(int, Vector2I, int, Vector2I)
Creates a coordinates-level proxy for the given identifiers. A proxy will map set of tile identifiers to another set of identifiers. The alternative tile ID is kept the same when using coordinates-level proxies.
This can be used to replace a tile in all TileMaps using this TileSet, as TileMap nodes will find and use the proxy's target tile when one is available.
Proxied tiles can be automatically replaced in TileMap nodes using the editor.
public void SetCoordsLevelTileProxy(int pSourceFrom, Vector2I coordsFrom, int sourceTo, Vector2I coordsTo)
Parameters
SetCustomDataLayerName(int, string)
Sets the name of the custom data layer identified by the given index. Names are identifiers of the layer therefore if the name is already taken it will fail and raise an error.
public void SetCustomDataLayerName(int layerIndex, string layerName)
Parameters
SetCustomDataLayerType(int, Type)
Sets the type of the custom data layer identified by the given index.
public void SetCustomDataLayerType(int layerIndex, Variant.Type layerType)
Parameters
SetNavigationLayerLayerValue(int, int, bool)
Based on value
, enables or disables the specified navigation layer of the TileSet navigation data layer identified by the given layerIndex
, given a navigation_layers layerNumber
between 1 and 32.
public void SetNavigationLayerLayerValue(int layerIndex, int layerNumber, bool value)
Parameters
SetNavigationLayerLayers(int, uint)
Sets the navigation layers (as in the navigation server) for navigation regions in the given TileSet navigation layer.
public void SetNavigationLayerLayers(int layerIndex, uint layers)
Parameters
SetOcclusionLayerLightMask(int, int)
Sets the occlusion layer (as in the rendering server) for occluders in the given TileSet occlusion layer.
public void SetOcclusionLayerLightMask(int layerIndex, int lightMask)
Parameters
SetOcclusionLayerSdfCollision(int, bool)
Enables or disables SDF collision for occluders in the given TileSet occlusion layer.
public void SetOcclusionLayerSdfCollision(int layerIndex, bool sdfCollision)
Parameters
SetPhysicsLayerCollisionLayer(int, uint)
Sets the physics layer (as in the physics server) for bodies in the given TileSet physics layer.
public void SetPhysicsLayerCollisionLayer(int layerIndex, uint layer)
Parameters
SetPhysicsLayerCollisionMask(int, uint)
Sets the physics layer (as in the physics server) for bodies in the given TileSet physics layer.
public void SetPhysicsLayerCollisionMask(int layerIndex, uint mask)
Parameters
SetPhysicsLayerPhysicsMaterial(int, PhysicsMaterial)
Sets the physics material for bodies in the given TileSet physics layer.
public void SetPhysicsLayerPhysicsMaterial(int layerIndex, PhysicsMaterial physicsMaterial)
Parameters
layerIndex
intphysicsMaterial
PhysicsMaterial
SetSourceId(int, int)
Changes a source's ID.
public void SetSourceId(int sourceId, int newSourceId)
Parameters
SetSourceLevelTileProxy(int, int)
Creates a source-level proxy for the given source ID. A proxy will map set of tile identifiers to another set of identifiers. Both the atlas coordinates ID and the alternative tile ID are kept the same when using source-level proxies.
This can be used to replace a source in all TileMaps using this TileSet, as TileMap nodes will find and use the proxy's target source when one is available.
Proxied tiles can be automatically replaced in TileMap nodes using the editor.
public void SetSourceLevelTileProxy(int sourceFrom, int sourceTo)
Parameters
SetTerrainColor(int, int, Color)
Sets a terrain's color. This color is used for identifying the different terrains in the TileSet editor.
public void SetTerrainColor(int terrainSet, int terrainIndex, Color color)
Parameters
SetTerrainName(int, int, string)
Sets a terrain's name.
public void SetTerrainName(int terrainSet, int terrainIndex, string name)
Parameters
SetTerrainSetMode(int, TerrainMode)
Sets a terrain mode. Each mode determines which bits of a tile shape is used to match the neighboring tiles' terrains.
public void SetTerrainSetMode(int terrainSet, TileSet.TerrainMode mode)
Parameters
terrainSet
intmode
TileSet.TerrainMode