Skip to content

TileSet

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

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

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

Overview

Stores tile sources and shared tilemap settings.

Syntax

public sealed class Electron2D.TileSet : Electron2D.Resource

Godot 4.7 C# profile compatibility

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

Tile set resource with tile size, source id mapping, source lookup and deterministic source listing.

Remarks

TileSet is a resource assigned to Electron2D.TileMapLayer. The 0.1.0 Preview supports atlas sources and a single rectangular cell size.

Thread Safety

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

Since

This type is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.TileMapLayer
  • Electron2D.TileSetAtlasSource

Members

Member Kind Summary
TileSize Property Gets or sets the size of a tilemap cell.
Electron2D.TileSet() Constructor Initializes a new instance of the Electron2D.TileSet type.
AddSource(Electron2D.TileSetSource, System.Int32) Method Adds a source to this tile set.
Clear() Method Removes all sources from this tile set.
GetSource(System.Int32) Method Gets a source by id.
GetSourceCount() Method Gets the number of sources stored by this tile set.
GetSourceId(System.Int32) Method Gets a source id by index.
HasSource(System.Int32) Method Checks whether a source id exists.
RemoveSource(System.Int32) Method Removes a source from this tile set.

Member Details

TileSize

Kind: Property

public Electron2D.Vector2I TileSize { get; set; }

Summary

Gets or sets the size of a tilemap cell.

Remarks

Rendering destination rectangles and tile collision placement use this size.

Value

The positive width and height used by Electron2D.TileMapLayer cells.

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.TileMapLayer.MapToLocal(Electron2D.Vector2I)

Electron2D.TileSet()

Kind: Constructor

public Electron2D.TileSet()

Summary

Initializes a new instance of the Electron2D.TileSet type.

Remarks

The tile set starts empty and uses a 16x16 cell size.

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.TileSet.AddSource(Electron2D.TileSetSource,System.Int32)

AddSource(Electron2D.TileSetSource, System.Int32)

Kind: Method

public System.Int32 AddSource(Electron2D.TileSetSource, System.Int32)(Electron2D.TileSetSource source, System.Int32 atlasSourceIdOverride)

Summary

Adds a source to this tile set.

Remarks

Automatically allocated ids use the lowest non-negative id that is not currently assigned.

Parameters

  • source: The source resource to add.
  • atlasSourceIdOverride: The requested source id, or -1 to allocate one.

Returns

The source id assigned to source.

Exceptions

  • System.ArgumentNullException: Thrown when source is null.
  • System.ArgumentOutOfRangeException: Thrown when atlasSourceIdOverride is less than -1.
  • System.InvalidOperationException: Thrown when the requested source id is already used.

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.TileSet.GetSource(System.Int32)

Clear()

Kind: Method

public System.Void Clear()()

Summary

Removes all sources from this tile set.

Remarks

This method keeps Electron2D.TileSet.TileSize unchanged.

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.TileSet.RemoveSource(System.Int32)

GetSource(System.Int32)

Kind: Method

public Electron2D.TileSetSource GetSource(System.Int32)(System.Int32 sourceId)

Summary

Gets a source by id.

Remarks

The returned source is the same resource instance that was passed to Electron2D.TileSet.AddSource(Electron2D.TileSetSource,System.Int32).

Parameters

  • sourceId: The source id to query.

Returns

The source resource, or null when no source has that id.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when sourceId is 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.TileSet.AddSource(Electron2D.TileSetSource,System.Int32)

GetSourceCount()

Kind: Method

public System.Int32 GetSourceCount()()

Summary

Gets the number of sources stored by this tile set.

Remarks

The count includes sources of every implemented source type.

Returns

The number of assigned sources.

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.TileSet.GetSourceId(System.Int32)

GetSourceId(System.Int32)

Kind: Method

public System.Int32 GetSourceId(System.Int32)(System.Int32 index)

Summary

Gets a source id by index.

Remarks

Source ids are returned in ascending numeric order.

Parameters

  • index: The zero-based index in sorted source id order.

Returns

The source id at the requested index.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when index is outside the stored source 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.TileSet.GetSourceCount

HasSource(System.Int32)

Kind: Method

public System.Boolean HasSource(System.Int32)(System.Int32 sourceId)

Summary

Checks whether a source id exists.

Remarks

This method does not validate the source resource contents.

Parameters

  • sourceId: The source id to query.

Returns

true when the source exists; otherwise, false.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when sourceId is 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.TileSet.GetSource(System.Int32)

RemoveSource(System.Int32)

Kind: Method

public System.Void RemoveSource(System.Int32)(System.Int32 sourceId)

Summary

Removes a source from this tile set.

Remarks

Removing a missing source does nothing. Existing tilemap cells that point to the source remain stored but will not render or collide.

Parameters

  • sourceId: The source id to remove.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when sourceId is 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.TileSet.HasSource(System.Int32)

Clone this wiki locally