Back to API Reference
Class

BaseModifier

abstract

Base class for logic that alters the appearance, layout, semantics, or behavior of ranges emitted by a RangeSource.

Remarks

Subclass and override the protected hooks (OnEnable, OnDisable, OnDestroy, OnApply, optionally PrepareForParallel). Lifecycle dispatching is driven by the framework (Style, the parse pipeline, CompositeModifier) — user code instantiates modifiers and hands them to Style; it should not invoke the lifecycle itself. Cycle (per parse pass on a UniText component): OnEnable runs once when the modifier first participates in a cycle — allocate pooled buffers and subscribe to UniText events here. OnApply runs for every tag/range matched in the current text. OnDisable runs at the start of the next cycle to unsubscribe event handlers; allocated buffers should stay alive so the next OnEnable can reuse them. OnDestroy runs when the modifier is removed from the component (style changed, font reload, component destroyed) — release pooled buffers and any other resources OnEnable acquired. Guaranteed to run exactly once per OnEnable-initiated resource acquisition, even when an intervening OnDisable has already cleared the subscription state. Granular reapplication re-runs OnApply over retained spans without a re-parse, once per span — so accumulators OnApply appends to must be cleared once per cycle, never at the start of OnApply itself. Override BeforeApply for that: the framework compares the host's apply-cycle stamp on each dispatch and calls it lazily before the modifier's first range of a new cycle (full parse and granular re-apply alike). There is no separate reset phase.

Derived Types(30)

Types that inherit from BaseModifier.

C
AlignmentModifier
Sets horizontal alignment, justify mode, and last-line alignment for the paragraphs it covers. Apply whole-text or per range/tag — each paragraph can differ.
C
BaseLineModifier
Base class for modifiers that render horizontal lines across text (underline, strikethrough).
C
BaseRangeDecorationModifier
Base class for modifier-authored geometry attached to final visual text ranges. It owns range accumulation, paint resolution, renderer handles and main-thread rebuild timing; subclasses only translate one immutable [[RangeDecorationContext]] into a [[RangeMeshWriter]].
C
CompositeModifier
Combines modifiers and splits semicolon-delimited parameters by child order.
C
DirectionModifier
Sets the paragraph base writing direction (UAX #9). Apply whole-text.
C
EffectModifier
Base class for modifiers that append duplicate glyph geometry behind or in front of the face (outline, shadow, extrude, glow, custom effects).
C
EllipsisModifier
Truncates text that overflows its container and appends an ellipsis (...).
C
EmptyModifier
A no-op modifier that performs no action.
C
FontFeatureModifier
Turns OpenType features on or off over a text range.
C
FontSizeMatchModifier
Normalizes mixed fonts to a common visual size by matching x-height or cap-height (CSS font-size-adjust). Target 0 = match the primary font; >0 = match that aspect value (metric ÷ font size) for every font. Apply whole-text.
C
GlyphResolutionModifier
Raises the atlas tile resolution of the glyphs in its range by up to two size classes above the font default. Grow-only and shared: the atlas key ignores tile size, so every component that shows the glyph reads one tile at the highest boost any range requested, and the tile only ever grows.
C
InlineMediaModifier<TEntry, TWrapper>
Shared base for modifiers that embed inline-flowed media (prefab instances, sprite quads, future GPU mesh subitems) into text. Subclasses pick the entry type and wrapper type, supply a typed provider field, and translate entries into wrapper state — the base owns the cluster mapping, shape/render passes, lifecycle of wrapper instances, and provider event subscription.
C
InteractiveModifier
Declares semantic interaction for ranges selected by a Style source. One per-component [[UniTextInteractions]] router owns input, geometry, overlap and pointer state; this modifier owns only authored policy, target events and optional default actions.
C
LineHeightModifier
Sets each line's height, per paragraph.
C
ListModifier
Renders list markers (bullets or numbers) for text items with automatic indentation.
C
LowercaseModifier
Transforms text to lowercase within marked ranges.
C
MathModifier
Typesets formulas captured by [[MathParseRule]] with metrics and stretchy glyphs from a dedicated OpenType MATH font.
C
ModifierGraphModifier
Modifier node that instantiates and forwards to a [[ModifierGraphPreset]] while preserving the ordinary modifier lifecycle, parameters, effects and graph traversal.
C
PaintOrderModifier
Sets the painter order of a range's paint layers ([[PaintOrder]]): layer-major (the component default) draws each layer across all glyphs before the next layer; glyph-major composites every layer of one glyph before the next glyph, so a later glyph's stroke or shadow overlaps earlier glyphs' fill. The axis is a single per-component channel — all layer modifiers follow it, overlapping ranges resolve innermost-wins, and unmarked text stays layer-major. Characters connected by the Unicode cursive joining algorithm (Arabic, Syriac, N'Ko, Mongolian, …) never split: each connected stretch keeps layer order and composites as one unit, so glyph-major Arabic stacks per word rather than per letter.
C
ParagraphSpacingModifier
Adds vertical spacing between paragraphs (text separated by line breaks).
C
PooledAttributeModifier<T>
Owns one pooled modifier attribute from initialization through destruction.
C
RangeCollectingModifier
Base for modifiers that collect codepoint ranges during apply and act on them in the Shaped phase — the channel through which a modifier influences wrapping. Subclasses implement [[ApplyRange]].
C
RevealModifier
Shows only the leading part of each covered range and hides the rest — the engine piece behind typewriter-style text reveal.
C
RollingModifier
Characters roll on a cyclic glyph wheel: every covered character found in [[Wheel]] renders as its wheel position minus the effective roll, with the fractional part shown as two stacked wheel glyphs sliding through the character's cell (one em of travel per step, clipped to the wheel's ink band). The default digit wheel is an odometer; a letter wheel with a trailing space is a split-flap board. Characters outside the wheel pass through untouched. Drive [[Roll]] toward 0 to settle on the real text; at 0 the modifier costs nothing.
C
RubyModifier
Sets ruby (furigana) — small annotation text placed above a base run to show its reading or meaning, as used in Japanese and other East-Asian typography.
C
ScrambleModifier
Decode effect: unresolved characters render as random glyphs from [[Charset]] and settle into the real text left-to-right as [[Progress]] grows. [[Phase]] churns the random picks. Both inputs are external and deterministic; the layout never reflows — replacements draw in the real glyphs' cells.
C
SemanticModifier
Publishes platform-neutral meaning, spoken text, states, actions and final bounds for range entities. Native accessibility integrations consume [[For]] instead of being named or invoked by this modifier.
C
SubMeshModifier
Base class for modifiers that emit a separate, owner-controlled sub-mesh rendered by its own CanvasRenderer with a user-supplied material (see [[MaterialModifier]]).
C
TextBoxTrimModifier
Trims vertical space above/below text to chosen metrics (CSS text-box-trim/text-box-edge): e.g. cap-height + baseline for optically centered UI labels. Apply whole-text.
C
UppercaseModifier
Transforms text to uppercase within marked ranges.
public bool IsInitialized{ get }

between OnEnable and the next OnDisable/OnDestroy: event handlers are currently subscribed. Useful for diagnostics and for nested composites that mirror the child lifecycle.

protected int CurrentApplyCycle{ get }
public void GetRanges()

Collects this modifier's materialized ranges from the current parse, in text order.

public RangeQuery Ranges()

Starts a query over this modifier's materialized ranges; chain filters, then materialize with Collect or take standing ownership with Own<TModifier,TValue>.

public OwnedParameterSet<TModifier,TValue> Own()

Takes standing ownership of one parameter across every range of this modifier, now and after every future parse.

protected void MarkMeshDirty()
protected void MarkPositionsDirty()
protected void MarkLayoutDirty()
protected void MarkTextDirty()
protected void MarkNestedStateChanged()

Forwards an exact transition owned by nested reusable state.

protected void MarkStructureChanged()
protected virtual void BeforeApply()

Runs once per apply cycle (full parse and granular re-apply alike), lazily before this modifier's first OnApply of the cycle. Bring accumulated state back to a valid start: clear buffers OnApply appends to (ranges?.FakeClear()), release externally held resources the re-run re-acquires (gradient ramp rows), restore derived flags. A granular re-apply replays the cycle inside the mesh phase without re-running the parse, shaping, or — while positions stay valid — layout, so state whose only producer is one of those phases must never be cleared or overwritten here and belongs in a container this method does not touch. Runs on the rebuild worker — keep it idempotent and free of Unity API calls. Overwrite-style attribute buffers need nothing here.

protected virtual void OnEnable()

Allocate buffers, subscribe to UniText events, and bring the modifier into the active state. Pairs one-to-one with OnDisable and OnDestroy.

protected virtual void OnDisable()

Unsubscribe from UniText events. Buffers and persistent state should remain allocated — OnDestroy is responsible for releasing them. Runs once per active cycle (at the start of the next parse pass).

protected virtual void OnDestroy()

Release resources allocated by OnEnable (pooled buffers, attribute data, registry subscriptions). Always runs after OnEnable ran at least once, even when the most recent cycle already drained subscriptions via OnDisable.

protected virtual void OnApply(RangeApplyContext context)

Applies this modifier to one entity segment. Override this hook to access identity, payload, source, revision and layered parameters without materializing a merged value.

protected UniTextBase uniText

The UniText component this modifier is bound to. Assigned by the framework via SetOwner; available to subclasses from OnEnable onward.

protected UniTextBuffers buffers

Shared text-processing buffers (codepoints, runs, shaped glyphs, attribute storage). Assigned by the framework alongside uniText.

See Also