Class UIFontReference
Serializable wrapper around a TMP_FontAsset that lets consumers configure
fonts in the Unity Inspector or at runtime without taking a direct dependency on
the TextMeshPro namespace.
Inherited Members
Namespace: Scylla.Core.Util.UI
Assembly: ScyllaCore.dll
Syntax
[Serializable]
public sealed class UIFontReference
Remarks
Any Scylla UI component that exposes a font setting accepts a
UIFontReference rather than a raw TMP_FontAsset. This
keeps the public API decoupled from TMP even though the implementation uses it
internally.
Always check HasFont before accessing FontAsset to avoid null reference exceptions when the Inspector field has not been assigned:
if (fontRef.HasFont)
textComponent.SetFont(fontRef);
Constructors
UIFontReference()
Initializes an empty font reference with no assigned font asset.
Declaration
public UIFontReference()
Remarks
Used by Unity's serialization system when deserializing Inspector data.
After construction HasFont returns false.
UIFontReference(TMP_FontAsset)
Initializes a font reference wrapping the specified TMP_FontAsset.
Declaration
public UIFontReference(TMP_FontAsset fontAsset)
Parameters
| Type | Name | Description |
|---|---|---|
| TMP_FontAsset | fontAsset | The TMP font asset to wrap. May be |
Properties
FontAsset
Gets the underlying TMP_FontAsset held by this reference.
Declaration
public TMP_FontAsset FontAsset { get; }
Property Value
| Type | Description |
|---|---|
| TMP_FontAsset | The assigned font asset, or |
HasFont
Gets whether this reference holds a non-null font asset.
Declaration
public bool HasFont { get; }
Property Value
| Type | Description |
|---|---|
| bool |
|
Methods
FromFontAsset(TMP_FontAsset)
Creates a UIFontReference from an existing TMP_FontAsset.
Declaration
public static UIFontReference FromFontAsset(TMP_FontAsset fontAsset)
Parameters
| Type | Name | Description |
|---|---|---|
| TMP_FontAsset | fontAsset | The font asset to wrap. May be |
Returns
| Type | Description |
|---|---|
| UIFontReference | A new UIFontReference whose FontAsset property
returns |