UniTextBase
Shared base for UniText components — handles text processing (Unicode, BiDi, shaping, line breaking, modifiers, emoji, font fallback, variable fonts). Concrete subclasses supply the rendering backend: UniText (Canvas) and UniTextWorld (world-space).
Derived Types(2)
Types that inherit from UniTextBase.
Nested Types
public UniTextDirtyFlags CurrentDirtyFlags{ get }Gets the current dirty flags indicating what needs rebuilding.
public TextProcessor TextProcessor{ get }Gets the text processor instance handling shaping and layout.
public UniTextMeshGenerator MeshGenerator{ get }Gets the mesh generator instance.
public UniTextFontProvider FontProvider{ get }Gets the font provider managing font assets and fallbacks.
public UniTextBuffers Buffers{ get }Gets the buffer container for text processing.
public ReadOnlyMemory<char> RawText{ get }The runtime source text — the last value assigned via Text or any SetText overload, before any resolver substitution. Zero-alloc.
public ReadOnlyMemory<char> ResolvedText{ get }Gets the substitute produced by the attached TextResolver on the last rebuild, or an empty memory when no resolver is attached or TryResolve returned. Zero-alloc. Test TextOverride for Resolver to know if this value is in use.
public ReadOnlyMemory<char> RenderedText{ get }Gets the text actually fed into the parsing / shaping / layout pipeline: the resolver's output if one is active, otherwise RawText. Zero-alloc. Still contains markup; for the markup-stripped form use CleanText.
public ReadOnlySpan<char> CleanText{ get }Gets RenderedText with parsed markup removed. Zero-alloc. The backing buffer is pooled and may be rewritten on the next parse — do not store the span; call new string(span) if you need a stable string.
public TextOverrideSource TextOverride{ get }Combination of flags describing which runtime source(s) are currently overriding the serialized Text. Flags may combine — for example, SetText | Resolver when a SetText buffer feeds an attached resolver that further substitutes the text.
public IUniTextResolver TextResolver{ get; set }Gets or sets a resolver that may override the source text before parsing without modifying the serialized text field. Useful for editor-time localization preview and runtime text-binding without dirtying scenes or prefabs. See IUniTextResolver for the contract.
public Vector2 ResultSize{ get }Gets the computed size of the rendered text.
public ReadOnlySpan<PositionedGlyph> ResultGlyphs{ get }Gets the positioned glyphs after processing.
public UniTextFont PrimaryFont{ get }Gets the effective primary font: the explicit Font if set, otherwise PrimaryFont from FontStack.
public IReadOnlyList<Style> Styles{ get }Local styles (modifier + parse rule pairs) registered on this component.
public IReadOnlyList<StylePreset> StylePresets{ get }Shared StylePreset assets applied in addition to local Styles.
public TextHighlighter Highlighter{ get; set }Gets or sets the text highlighter for visual feedback on interactions.
public UniTextFont Font{ get; set }Optional explicit primary font. When set, overrides the primary picked from FontStack; the families in FontStack still serve as fallback for characters this font doesn't have.
public UniTextFontStack FontStack{ get; set }Gets or sets the font collection.
public Vector4 Padding{ get; set }Inner inset between the RectTransform edge and the text layout area. Components: x = Left, y = Bottom, z = Right, w = Top (same convention as raycastPadding). Increasing a side shrinks the text area on that side; the hit-test/raycast area is not affected.
public HorizontalAlignment HorizontalAlignment{ get; set }Gets or sets the horizontal text alignment.
public VerticalAlignment VerticalAlignment{ get; set }Gets or sets the vertical text alignment.
public UniTextRenderMode RenderMode{ get; set }Gets or sets the text rendering mode (SDF for rounded, MSDF for sharp corner effects).
public Color color{ get; set }public RectTransform RenderRoot{ get }Transform under which this component parents its generated render children (glyph sub-meshes, inline media). Main thread only — the Canvas backend lazily creates a hidden container.
public TextHitResult LastHoverResult{ get }Gets the last hover hit test result.
public InteractiveRange CurrentHoverRange{ get }Gets the interactive range currently being hovered, if any.
Height the text content needs inside the padded inner rect (accounts for auto-sizing). Does not include vertical Padding — this is the content-box height, matching CSS height with box-sizing: content-box. The ILayoutElement contract adds vertical padding so ContentSizeFitter sizes the outer RectTransform to fit content + padding.
public void SetText(ReadOnlyMemory<char> source)Sets the text to render without writing to the serialized text field. The change is visible at runtime and in edit mode without marking the scene or prefab as dirty — suitable for editor-time preview (localization) or transient runtime substitution.
public void SetText(StringBuilder source)Sets the text to render from a StringBuilder without writing to the serialized text field and without allocating a string. The contents are copied into a pooled internal buffer, so the supplied StringBuilder may be mutated freely after the call.
public void SetText(ReadOnlySpan<char> source)Sets the text to render from a character span without writing to the serialized text field and without allocating a string. The span is copied into a pooled internal buffer, so its backing storage may be reused or released immediately after the call — making this the safe bridge from a pool-rented builder.
public Rect GetPaddedRect()The rect with Padding applied: origin shifted by (Left, Bottom), size shrunk by (Left+Right, Bottom+Top), clamped to non-negative. Main-thread only.
public void AddRule(IParseRule rule)Adds a standalone parse rule (one that operates without a modifier, e.g. <noparse>). The rule must report IsStandalone as.
public bool RemoveRule(IParseRule rule)Removes a standalone rule previously added via AddRule.
Hides the text while keeping its built layout, mesh and pooled buffers intact: stops drawing and pointer hit-testing without tearing down the pipeline. Prefer this over disabling the GameObject/component or assigning empty text for text shown and hidden repeatedly (pooled lists, tooltips, HUD) — those force a full pipeline rebuild on every re-show, whereas Show after Hide is free. No-op if already hidden.
public void CollectRangeEntries(int startCluster, int endCluster, PooledList<LineRangeEntry> output)Collects per-line geometric runs of positioned glyphs whose clusters fall inside [startCluster, endCluster). Output bounds are in mesh-local coordinates with X clamped to each line's visible content extent (trailing whitespace excluded via width). One LineRangeEntry is emitted per contiguous run within a line — multiple entries per line are possible if the matched clusters are non-contiguous in visual order.
Gets bounding rectangles for a cluster range. One Rect per contiguous run of glyphs within a line that falls inside [startCluster, endCluster). Trailing whitespace at line ends is excluded (CSS Text §4.1.3). Empty wrapped lines whose break codepoint lies inside the range receive a synthetic narrow rect for caret/selection rendering.
public TextHitResult HitTest(Vector2 localPosition, float maxDistance)Performs hit testing in local coordinates.
public TextHitResult HitTestScreen(Vector2 screenPosition, Camera eventCamera, float maxDistance)Performs hit testing from screen coordinates.
Unity callback invoked after Animator writes animated properties into this component's serialized fields. Subclasses delegate to their composed AnimationHandlerBase<T> to diff the animated state and aggregate the resulting UniTextDirtyFlags in a single SetDirty call.
Diffs animated fields against the cached baseline through the subclass's animation handler. Implementations should forward to their composed AnimationHandlerBase<T> instance.
public IEnumerable<Style> GetStylesOfType()Enumerates every style whose modifier is of type T, local first.
public IEnumerable<Style> GetStylesOfType()Enumerates every style whose modifier is assignable to modifierType, local first.
Returns the first modifier of type T, or if none. Unlike the style queries above, also searches CompositeModifier children.
Same lookup as GetModifier<T>, also returning the Style that owns the found modifier (for a match inside a CompositeModifier — the composite's style).
True when the style targets the entire text — either it has no rule (the canonical no-constraint form created by WholeText) or it carries a RangeRule whose single entry resolves to the full range.
True only for a RangeRule instance that covers the full text. Use IsWholeTextStyle when checking a style — that variant also accepts the canonical rule-less form.
public Vector2 MeasureText()Measures the size text occupies under the given constraints and setting overrides — the displayed text, layout and mesh are left untouched.
protected ReadOnlyMemory<char> sourceTextprotected TextProcessor textProcessorprotected UniTextMeshGenerator meshGeneratorprotected UniTextBuffers buffersprotected List<UniTextRenderData> renderDatapublic CachedTransformData cachedTransformDataCached transform data captured before parallel processing.
public Action RebuildingRaised before text is rebuilt.
public Action BeforeGenerateMeshRaised after glyph positioning, before mesh generation. Last chance to inspect or inject positioned glyphs (used by per-glyph modifiers).
public Action RectHeightChangedRaised when the RectTransform height changes.
public Action<UniTextDirtyFlags> DirtyFlagsChangedRaised when dirty flags change, indicating what needs rebuilding.
public static Action BeforeProcessRaised before any text processing in the current canvas update cycle.
public static Action MeshAppliedRaised after meshes are applied to renderers, before canvas rendering begins.
public static Action AfterProcessRaised after all text processing is complete, after MeshApplied.
public Action<TextHitResult> TextClickedRaised when any text is clicked, providing hit test details.
public Action<InteractiveRangeHit> RangeClickedRaised when an interactive range is clicked.
public Action<InteractiveRangeHit> RangeEnteredRaised when the pointer enters an interactive range (desktop only).
public Action<InteractiveRangeHit> RangeExitedRaised when the pointer exits an interactive range (desktop only).
public Action<TextHitResult> HoverChangedRaised when the hovered glyph/cluster changes (desktop only).
public Action AnimatedRaised after Unity Animator applies animated property values to this component, once the base field diff has issued the corresponding SetDirty. Modifiers with their own animatable fields should subscribe and run an equivalent diff over their state, calling SetDirty with the flags that match their effect.
