Back to API Reference
Class

StylePreset

Shareable, project-asset container of Style entries that components apply in bulk via AddStylePreset or via GlobalStylePreset.

Remarks

Mutating the preset at runtime through AddStyle / RemoveStyle / ClearStyles raises Changed; every UniTextBase that has this preset attached (locally or as the global preset) discards its runtime preset copies and re-instantiates from the new contents on the next frame.
public IReadOnlyList<Style> Styles{ get }

Snapshot view of the contained styles. Mutate via AddStyle / RemoveStyle / ClearStyles so subscribers are notified.

public void AddStyle()

Appends a style to the preset and raises Changed.

public bool RemoveStyle()

Removes the first occurrence of style. Returns on success.

public void RemoveStyleAt()

Removes the style at the given index and raises Changed.

public void ClearStyles()

Removes every style from the preset and raises Changed.

public Action Changed

Raised whenever the preset's styles list is mutated — either through the editor inspector (OnValidate) or programmatically via AddStyle / RemoveStyle / ClearStyles. Subscribers are expected to be idempotent (the event may fire several times in a row on rapid edits).