Back to API Reference
Class

SubMeshModifier

abstract

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 alpha zero'd into base mesh) will be re-applied in the next onGlyph pass. onGlyph — subclass overrides ShouldIncludeCurrentGlyph and, when true, the base class copies the face quad (4 verts) from the generator into its own per-atlas buffer (SDF atlas vs emoji atlas are kept separate). onCollectSubMeshes — the base class uploads owned buffers into private Mesh instances and appends up to two entries (text + emoji) to the render-data list, with the material, atlas, 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.
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 GetMaterialForSlot(Slot slot)

Resolves the material for a given slot. Return to skip emitting that slot.

protected virtual GlyphAtlas GetAtlasForSlot()
protected virtual RenderOrder GetRenderOrder()
protected virtual int GetSortIndex()

Stable sort key within the same RenderOrder group (lower renders first).

protected virtual void OnQuadAppended(Slot slot, int vertexStart, UniTextMeshGenerator gen)

Called after a glyph's quad is copied into the slot buffers. 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) in the slot buffer identified by slot.

protected void SetSubMeshUv2()

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

protected void SetSubMeshUv3()

Writes a value into UV3 channel for a vertex in the slot 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[] GetSlotColors()

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

protected Vector3[] GetSlotVertices()

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

protected void ExpandSubMeshQuad(Slot slot, int vertexStart, float delta)

Expands a 4-vertex quad outward on all sides by delta em-units. Updates both positions and UV0 in sync so the atlas sample stays aligned. Mirror of ExpandQuad but operates on the sub-mesh slot buffers. No-op for non-positive deltas or when UV0 has not been written yet.

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.