Table of Contents

Class TextureRegionAtlas

Namespace
Myra.Graphics2D.TextureAtlases
Assembly
Myra.dll

Represents a collection of texture regions derived from a single texture, with support for both LibGDX and Myra XML formats.

public class TextureRegionAtlas
Inheritance
TextureRegionAtlas
Inherited Members

Properties

Image

Gets or sets the image file name or path for this texture atlas.

public string Image { get; set; }

Property Value

string

this[string]

Gets or sets a texture region by its identifier.

public TextureRegion this[string name] { get; set; }

Parameters

name string

The identifier of the region.

Property Value

TextureRegion

The texture region with the specified identifier.

Name

User-specified name

public string Name { get; set; }

Property Value

string

Regions

Gets the dictionary of texture regions keyed by their identifiers.

public Dictionary<string, TextureRegion> Regions { get; }

Property Value

Dictionary<string, TextureRegion>

Texture

Gets the texture associated with this atlas.

public Texture2D Texture { get; }

Property Value

Texture2D

Methods

EnsureRegion(string)

Gets a texture region by its identifier, throwing an exception if not found.

public TextureRegion EnsureRegion(string id)

Parameters

id string

The identifier of the region.

Returns

TextureRegion

The texture region with the specified identifier.

Exceptions

ArgumentNullException

The region with the specified identifier is not found.

FromXml(string, Func<string, Texture2D>)

Loads a texture atlas from Myra XML format.

public static TextureRegionAtlas FromXml(string xml, Func<string, Texture2D> textureGetter)

Parameters

xml string

The atlas data in Myra XML format.

textureGetter Func<string, Texture2D>

A function that retrieves the texture given its filename.

Returns

TextureRegionAtlas

A new TextureRegionAtlas loaded from the provided XML.

ToString()

Returns the name of the texture atlas.

public override string ToString()

Returns

string

The atlas name.

ToXml()

Converts the texture atlas to an XML string representation.

public string ToXml()

Returns

string

An XML string containing all regions in this atlas.