Back to API Reference
Interface
IUniTextResolver
abstract
Hook that can override the source text of a UniTextBase before it is parsed, shaped and laid out — without touching the serialized text field.
Remarks
Typical use cases: editor-time localization preview (swap keys for translated strings without dirtying scenes or prefabs), runtime localization bound to a language signal, or any derived-text scenario where the authored text is a template or key. Assign via
TextResolver. When a resolver is attached and TryResolve returns, the component renders the override; the serialized text remains untouched, so scenes and prefabs are not marked dirty. Threading — same two-phase contract as BaseModifier: PrepareForParallel always runs on the main thread. Override to cache values from Unity APIs that are main-thread-only (localization tables, ScriptableObject lookups, AssetDatabase in editor). TryResolve may run on a worker thread when batched parallel processing is active. Do not call Unity APIs directly from it — read from caches populated in PrepareForParallel. To trigger a rebuild when your external source changes (language switch, scriptable object edit, etc.) call owner.SetDirty(UniTextDirtyFlags.Text) — the owner is supplied to OnAttached.public virtual void OnAttached(UniTextBase owner)Called after the resolver has been assigned to owner. Use this to cache the owner reference and subscribe to any external signal that should trigger a re-resolve (e.g. a localization language-changed event).
public virtual void OnDetached(UniTextBase owner)Called when the resolver is replaced, cleared, or its owner is destroyed. Unsubscribe from any signals registered in OnAttached.
public abstract bool TryResolve(ReadOnlyMemory<char> source, ReadOnlyMemory<char> result)Produces the effective text to feed into the parsing pipeline.
