Skip to content

ModuleContext

ClassTextStudio.ThreeDTextStudio.3D
public sealed class ModuleContext

Context passed to modules during pipeline execution. Contours are detached copies of the font-outline cache, so pre-geometry edits cannot corrupt later text. All array contents are mutable in place; modules may modify vertex / normal / UV arrays inside TextStudio.ThreeD.ModuleContext.GlyphMeshes, reassign whole entries via TextStudio.ThreeD.ModuleContext.ReplaceGlyphMesh(System.Int32%2cTextStudio.ThreeD.GlyphMeshData), or move glyph offsets during TextStudio.ThreeD.Module3DBase.PostGeometry(TextStudio.ThreeD.ModuleContext). Changes are picked up by the mesh assembler immediately after PostGeometry returns.

public bool TryGetContour(int visibleGlyphIndex, out ContourState contour)

Gets the detached contour state for one visible glyph.

Parameters

Name Type
visibleGlyphIndex System.Int32
contour TextStudio.ThreeD.ContourState

Returns

System.Boolean

public bool SetContour(int visibleGlyphIndex, ContourState contour)

Replaces the detached contour state for one visible glyph.

Parameters

Name Type
visibleGlyphIndex System.Int32
contour TextStudio.ThreeD.ContourState

Returns

System.Boolean

public bool SetEntryOffset(int entryIndex, Vector3 offset)

Changes the generated base position for one glyph-layer entry.

Parameters

Name Type
entryIndex System.Int32
offset UnityEngine.Vector3

Returns

System.Boolean

public TextStudio3DWritableBuffer<T> GetWritableBuffer<T>(int slot, int minimumCount = 0)

Returns renderer-owned scratch storage for an element type and caller-defined slot. Capacity grows on demand, then the same buffer is reused without allocation on warmed calls. Contents are temporary and may be overwritten by the next module callback.

Parameters

Name Type
slot System.Int32
minimumCount System.Int32

Returns

TextStudio.ThreeD.TextStudio3DWritableBuffer{{T}}

public Vector3[] GetRenderedGlyphOffsets()

Returns one generated position per rendered glyph, using the first geometry entry for each glyph. Whitespace and glyphs without generated geometry are omitted.

Returns

UnityEngine.Vector3[]

WriteRenderedGlyphOffsets(TextStudio3DWritableBuffer)

Section titled “WriteRenderedGlyphOffsets(TextStudio3DWritableBuffer)”
public int WriteRenderedGlyphOffsets(TextStudio3DWritableBuffer<Vector3> destination)

Writes one offset per rendered glyph into retained caller-selected scratch storage. This is the allocation-free alternative to TextStudio.ThreeD.ModuleContext.GetRenderedGlyphOffsets.

Parameters

Name Type
destination TextStudio.ThreeD.TextStudio3DWritableBuffer{UnityEngine.Vector3}

Returns

System.Int32

public Vector3 GetRenderedGlyphCenter()

Returns the average generated position using one entry per rendered glyph. This avoids weighting glyphs by their layer count and does not allocate.

Returns

UnityEngine.Vector3

public void ReplaceGlyphMesh(int entryIndex, GlyphMeshData newData)

Replace the geometry for a single glyph entry. The new data must preserve the nine built-in ranges in MaterialRegion order and may append ranges registered through TextStudio.ThreeD.ModuleContext.MaterialRegions, or pass null to drop region metadata. Out-of-range indices are ignored.

Parameters

Name Type
entryIndex System.Int32
newData TextStudio.ThreeD.GlyphMeshData

public ModuleContext()

public TextStudio3DText Host { get; }

The renderer currently executing the module pipeline.

Returns

TextStudio.ThreeD.TextStudio3DText

public Mesh FinalMesh { get; }

The assembled mesh, available during post-assembly callbacks.

Returns

UnityEngine.Mesh

public string Text { get; }

The resolved plain/rich text used for this build.

Returns

System.String

public int GlyphCount { get; }

Number of visible glyph slots represented by TextStudio.ThreeD.ModuleContext.Contours.

Returns

System.Int32

public VariableHolder Variables { get; }

Optional typed variables assigned to the renderer.

Returns

TextStudio.ThreeD.VariableHolder

public TextStudio3DMaterialRegionRegistry MaterialRegions { get; }

Semantic material regions declared by active modules for this build. Custom providers can find their registered value, expand a glyph’s region table, and assign appended ranges.

Returns

TextStudio.ThreeD.TextStudio3DMaterialRegionRegistry

public TextStudio3DEntryCollection Entries { get; }

Allocation-free read-only views over the active glyph-layer entries.

Returns

TextStudio.ThreeD.TextStudio3DEntryCollection

public TextStudio3DGlyphCollection Glyphs { get; }

Allocation-free read-only views indexed by visible glyph identity.

Returns

TextStudio.ThreeD.TextStudio3DGlyphCollection