logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class SerenityFontAssetGenerator

    Turns a source UnityEngine.Font into a persisted TMPro.TMP_FontAsset.

    Inheritance
    object
    SerenityFontAssetGenerator
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    Namespace: Serenity.Ui.Infrastructure.Editor
    Assembly: Serenity.UnityUi.Infrastructure.Editor.dll
    Syntax
    public static class SerenityFontAssetGenerator
    Remarks

    Mirrors TMPro's own "Create Font Asset" flow (TMPro_FontAssetCreatorWindow), which is not a one-call affair: TMPro.TMP_FontAsset.CreateFontAsset(UnityEngine.Font) builds the asset with its atlas texture and material populated in memory, but those two are not project assets until they are explicitly added as sub-assets — and they can only be added after the parent has been written. Getting that order wrong produces a font asset that looks right in the inspector and renders nothing at runtime.

    Shared because more than one Serenity tool now lets an author pick a font: the theme wizard was first, and anything else that offers the same choice must produce the same asset in the same shape rather than re-deriving this sequence.

    Methods

    Generate(Font, string, string, List<string>)

    Generates a TMP font asset from a source font and writes it to the project.

    Declaration
    public static TMP_FontAsset Generate(Font sourceFont, string folder, string assetName, List<string> createdPaths = null)
    Parameters
    Type Name Description
    Font sourceFont

    The .ttf/.otf font to build from.

    string folder

    Project folder to write into; created when it does not exist.

    string assetName

    File name, without extension or the SDF suffix.

    List<string> createdPaths

    Collects every path written, so a caller can roll back. May be null.

    Returns
    Type Description
    TMP_FontAsset

    The imported font asset.

    Exceptions
    Type Condition
    ArgumentNullException

    The source font is null.

    InvalidOperationException

    TMPro could not build or import the asset.

    In this article
    © 2026 Serenity. All Rights Reserved