Back to API Reference
Class

SubMeshModifier

abstract
Inherits:BaseModifier
Implements:ILayer

Base class for modifiers that emit a separate, owner-controlled sub-mesh rendered by its own CanvasRenderer with a user-supplied material (see MaterialModifier).

Remarks

Lifecycle per frame: onRebuildStart — own buffers are cleared; any persistent state (e.g. Replace-mode claim of the base face) will be re-applied in the next onGlyph pass. The geometry-consumer tail of onGlyph — subclass overrides ShouldIncludeCurrentGlyph and, when true, the base class copies the completed face quad (4 verts) from the generator into its own buffer. SDF, MSDF and emoji glyphs share it — the per-glyph mode rides the vertex stream (UV1.w), so one material renders them all. onCollectSubMeshes — the base class appends one entry to the render-data list, with the material, order and sort index chosen by the subclass. Compared to EffectModifier, which bakes its duplicates into the same mesh as the face pass, SubMeshModifier keeps its vertices in isolated local buffers because each sub-mesh is bound to a distinct material and CanvasRenderer.

Derived Types(1)

Types that inherit from SubMeshModifier.

public int LayerSequence{ get; set }
public bool RendersBehindFill{ get }
public bool ClaimsFill{ get }
protected abstract bool ShouldIncludeCurrentGlyph()

Tells the base class whether the glyph currently being emitted by the generator should be copied into this modifier's sub-mesh. Inspect uniText.MeshGenerator fields (currentCluster, faceBaseIdx, font.IsColor, etc.) for the decision.

protected abstract Material GetMaterial()

Resolves the sub-mesh material. Return to skip emitting.

protected virtual int GetSortIndex()

Stable sort key within the same layer sequence (lower renders first).

protected virtual void OnQuadAppended(int vertexStart, UniTextMeshGenerator gen)

Called after a glyph's quad is copied into the sub-mesh buffer. Override to write custom UV2/UV3 data for the just-appended four vertices, or to modify colors/positions. The four vertices occupy indices [vertexStart, vertexStart + 4).

protected void SetSubMeshUv2()

Writes a value into UV2 channel for a vertex in the buffer (auto-allocates channel).

protected void SetSubMeshUv3()

Writes a value into UV3 channel for a vertex in the buffer (auto-allocates channel).

protected void SetSubMeshUv2Quad()

Writes the same value to UV2 for all 4 vertices of a quad (indices [vertexStart..+4)).

protected void SetSubMeshUv3Quad()

Writes the same value to UV3 for all 4 vertices of a quad (indices [vertexStart..+4)).

protected Color32[] GetSubMeshColors()

Direct access to the sub-mesh color buffer for read/write on already-appended vertices.

protected Vector3[] GetSubMeshVertices()

Direct access to the sub-mesh vertex buffer for read/write on already-appended vertices.

protected void ExpandSubMeshQuad(int vertexStart, float delta)

Expands a 4-vertex quad outward on all sides by delta UV0 units, moving the positions through the quad's own UV0→pixel scale. Uses the same deformation-aware position and UV0 expansion as the main mesh.

protected override void OnEnable()
protected override void OnDisable()
protected override void OnDestroy()
protected virtual void OnBeforeRebuild()

Called at the start of every rebuild (before any onGlyph). Override to refresh derived state (e.g. runtime material clones) that depends on the generator's current mode.