Back to API Reference
Class

MaterialModifier

Applies a user-authored Material to a text range by emitting a dedicated sub-mesh with its own CanvasRenderer.

Remarks

The custom shader must include UniText_Custom.cginc — see Assets/Create/UniText/Custom Material Shader for a working template. The glyph atlases are global shader bindings and must NOT appear in the shader's Properties block; per-glyph user data is written into TEXCOORD2 / TEXCOORD3 (see constantUv2, constantUv3, glyphDataWriter and OnWriteGlyphUV). Default renderOrder is Replace: the base pass is suppressed on the range (the face quad is claimed and not recorded into the main mesh). Use Keep to keep the base pass and stack the custom material as its own layer, ordered by this modifier's position in Styles. Parameter: optional tint color. Format: <mat=#RRGGBBAA> or <mat=red>. The tint multiplies the vertex color that the shader receives. Replace suppresses the base face structurally: the glyph's base quad is not recorded, so the result is independent of where the modifier sits among other Styles. Paint layers (stroke, shadow, glow) are separate quads at their own sequence and still render over/under it. Emoji glyphs are handled identically to text — the unified vertex-mode contract lets the one custom material render every glyph mode.

Nested Types

public bool ClaimsFill{ get }
protected bool UseVirtualWriter{ get }

When true, OnQuadAppended calls OnWriteGlyphUV even if glyphDataWriter is null. Set to in subclasses that override OnWriteGlyphUV.

protected override bool ShouldIncludeCurrentGlyph()
protected override Material GetMaterial()
protected override int GetSortIndex()
protected override void OnQuadAppended()
protected virtual void OnWriteGlyphUV()

Override to write per-glyph data into the sub-mesh's TEXCOORD2 / TEXCOORD3. Called once per included glyph. Default implementation returns constantUv2 / constantUv3.

protected override void OnEnable()
protected override void OnBeforeRebuild()
protected override void OnDestroy()
protected override void BeforeApply()
protected override void OnApply()
public MaterialGlyphWriter glyphDataWriter

Optional per-glyph data writer. Takes precedence over OnWriteGlyphUV.