Skip to content

TileSetAtlasSource

Eduard Gushchin edited this page Jun 24, 2026 · 3 revisions

Home | API by Category | Complete API Index | API Compatibility

Field Value
Full name Electron2D.TileSetAtlasSource
Namespace Electron2D
Kind class
Category Rendering

Overview

Provides a tile set source backed by a texture atlas.

Syntax

public sealed class Electron2D.TileSetAtlasSource : Electron2D.TileSetSource

Godot 4.7 C# profile compatibility

Profile: Electron2D 0.1.0 2D
Status: Partial / Not verified
Out of profile: yes
Godot reference: TileSetAtlasSource

Atlas-backed tile source with texture region size, tile registration, tile data lookup and source rectangle queries.

Remarks

TileSetAtlasSource maps atlas coordinates to Electron2D.TileData and texture regions. It is the only tile source implemented by the 0.1.0 Preview runtime.

Thread Safety

This type is not synchronized. Create and mutate atlas sources on the main scene thread or during loading.

Since

This type is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.TileData
  • Electron2D.TileSet

Members

Member Kind Summary
Texture Property Gets or sets the atlas texture sampled by this source.
TextureRegionSize Property Gets or sets the size of one atlas tile region in pixels.
Electron2D.TileSetAtlasSource() Constructor Initializes a new instance of the Electron2D.TileSetAtlasSource type.
CreateTile(Electron2D.Vector2I, Electron2D.Vector2I) Method Creates tile data for an atlas coordinate.
GetTileData(Electron2D.Vector2I, System.Int32) Method Gets the tile data for an atlas coordinate.
GetTileId(System.Int32) Method Gets the atlas coordinates of a tile by index.
GetTileTextureRegion(Electron2D.Vector2I, System.Int32) Method Gets the texture region used by a tile.
GetTilesCount() Method Gets the number of tiles stored by this atlas source.
HasTile(Electron2D.Vector2I) Method Checks whether tile data exists for an atlas coordinate.
RemoveTile(Electron2D.Vector2I) Method Removes tile data for an atlas coordinate.

Member Details

Texture

Kind: Property

public Electron2D.Texture2D Texture { get; set; }

Summary

Gets or sets the atlas texture sampled by this source.

Remarks

TileMapLayer skips cells that reference a source without a texture.

Value

The texture containing tile regions, or null when no texture is assigned.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Texture2D

TextureRegionSize

Kind: Property

public Electron2D.Vector2I TextureRegionSize { get; set; }

Summary

Gets or sets the size of one atlas tile region in pixels.

Remarks

A tile at atlas coordinates (x, y) uses a source rectangle whose position is (x * width, y * height).

Value

The positive width and height used to compute source rectangles.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when either component is less than or equal to zero.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.TileSetAtlasSource.GetTileTextureRegion(Electron2D.Vector2I,System.Int32)

Electron2D.TileSetAtlasSource()

Kind: Constructor

public Electron2D.TileSetAtlasSource()

Summary

Initializes a new instance of the Electron2D.TileSetAtlasSource type.

Remarks

The source starts without a texture and uses a 16x16 texture region size until configured otherwise.

Thread Safety

This constructor is not synchronized. Call it from the thread that owns the resource being created.

Since

This constructor is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.TileSetAtlasSource.Texture

CreateTile(Electron2D.Vector2I, Electron2D.Vector2I)

Kind: Method

public System.Void CreateTile(Electron2D.Vector2I, Electron2D.Vector2I)(Electron2D.Vector2I atlasCoords, Electron2D.Vector2I sizeInAtlas)

Summary

Creates tile data for an atlas coordinate.

Remarks

Recreating an existing tile keeps the existing Electron2D.TileData and updates only its atlas-cell size.

Parameters

  • atlasCoords: The atlas coordinates identifying the tile.
  • sizeInAtlas: The positive tile size in atlas cells.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when atlas coordinates are negative or size components are not positive.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.TileSetAtlasSource.GetTileData(Electron2D.Vector2I,System.Int32)

GetTileData(Electron2D.Vector2I, System.Int32)

Kind: Method

public Electron2D.TileData GetTileData(Electron2D.Vector2I, System.Int32)(Electron2D.Vector2I atlasCoords, System.Int32 alternativeTile)

Summary

Gets the tile data for an atlas coordinate.

Remarks

The 0.1.0 Preview stores only the default alternative tile, but the parameter is accepted for call-site compatibility.

Parameters

  • atlasCoords: The atlas coordinates identifying the tile.
  • alternativeTile: The alternative tile id.

Returns

The tile data, or null when the tile does not exist.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when atlas coordinates or the alternative tile id are negative.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.TileSetAtlasSource.CreateTile(Electron2D.Vector2I,Electron2D.Vector2I)

GetTileId(System.Int32)

Kind: Method

public Electron2D.Vector2I GetTileId(System.Int32)(System.Int32 index)

Summary

Gets the atlas coordinates of a tile by index.

Remarks

Tiles are ordered by Y coordinate and then X coordinate for stable serialization and tests.

Parameters

  • index: The zero-based index in sorted tile order.

Returns

The atlas coordinates of the tile.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when index is outside the stored tile range.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.TileSetAtlasSource.GetTilesCount

GetTileTextureRegion(Electron2D.Vector2I, System.Int32)

Kind: Method

public Electron2D.Rect2 GetTileTextureRegion(Electron2D.Vector2I, System.Int32)(Electron2D.Vector2I atlasCoords, System.Int32 alternativeTile)

Summary

Gets the texture region used by a tile.

Remarks

The returned region is based on Electron2D.TileSetAtlasSource.TextureRegionSize and the tile's size in atlas cells.

Parameters

  • atlasCoords: The atlas coordinates identifying the tile.
  • alternativeTile: The alternative tile id.

Returns

The source rectangle in atlas texture pixels.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when atlas coordinates or the alternative tile id are negative.
  • System.InvalidOperationException: Thrown when the tile does not exist.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.TileSetAtlasSource.TextureRegionSize

GetTilesCount()

Kind: Method

public System.Int32 GetTilesCount()()

Summary

Gets the number of tiles stored by this atlas source.

Remarks

The count includes tiles even when Electron2D.TileSetAtlasSource.Texture is not assigned.

Returns

The number of default alternative tiles.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.TileSetAtlasSource.GetTileId(System.Int32)

HasTile(Electron2D.Vector2I)

Kind: Method

public System.Boolean HasTile(Electron2D.Vector2I)(Electron2D.Vector2I atlasCoords)

Summary

Checks whether tile data exists for an atlas coordinate.

Remarks

This method checks the default alternative tile entry.

Parameters

  • atlasCoords: The atlas coordinates identifying the tile.

Returns

true when the tile exists; otherwise, false.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when atlas coordinates are negative.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.TileSetAtlasSource.CreateTile(Electron2D.Vector2I,Electron2D.Vector2I)

RemoveTile(Electron2D.Vector2I)

Kind: Method

public System.Void RemoveTile(Electron2D.Vector2I)(Electron2D.Vector2I atlasCoords)

Summary

Removes tile data for an atlas coordinate.

Remarks

Removing a missing tile does nothing.

Parameters

  • atlasCoords: The atlas coordinates identifying the tile.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when atlas coordinates are negative.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.TileSetAtlasSource.HasTile(Electron2D.Vector2I)

Clone this wiki locally