docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class Registry

    Registry for managing grammars and themes

    Inheritance
    object
    Registry
    Implements
    IDisposable
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Unity.AppUI.TextMateLib
    Assembly: Unity.AppUI.TextMateLib.dll
    Syntax
    public class Registry : IDisposable

    Constructors

    Registry()

    Creates a new grammar registry

    Declaration
    public Registry()

    Methods

    AddGrammarFromFile(string)

    Adds a grammar to the registry from a JSON file

    Declaration
    public void AddGrammarFromFile(string grammarPath)
    Parameters
    Type Name Description
    string grammarPath

    Path to the grammar JSON file

    Exceptions
    Type Condition
    ArgumentNullException

    Thrown when grammarPath is null or empty

    InvalidOperationException

    Thrown when the grammar fails to load

    AddGrammarFromJson(string)

    Adds a grammar to the registry from a JSON string

    Declaration
    public void AddGrammarFromJson(string jsonContent)
    Parameters
    Type Name Description
    string jsonContent

    JSON content of the grammar

    Exceptions
    Type Condition
    ArgumentNullException

    Thrown when jsonContent is null or empty

    InvalidOperationException

    Thrown when the grammar fails to load

    Dispose()

    Releases the native resources

    Declaration
    public void Dispose()

    ~Registry()

    Finalizer to ensure resources are released

    Declaration
    protected ~Registry()

    GetColorMap()

    Gets the color map from the registry after a theme has been set. Color IDs in encoded tokens are indices into this array.

    Declaration
    public string[] GetColorMap()
    Returns
    Type Description
    string[]

    The theme color palette as hex strings, indexed by color ID.

    LoadGrammar(string)

    Loads a grammar by scope name

    Declaration
    public Grammar LoadGrammar(string scopeName)
    Parameters
    Type Name Description
    string scopeName

    The scope name (e.g., "source.js")

    Returns
    Type Description
    Grammar

    A Grammar instance for the requested scope

    Exceptions
    Type Condition
    ArgumentNullException

    Thrown when scopeName is null or empty

    InvalidOperationException

    Thrown when the grammar fails to load

    SetThemeFromJson(string)

    Sets the color theme on the registry from a JSON string. Must be called before using TokenizeLine2 for themed output.

    Declaration
    public void SetThemeFromJson(string jsonContent)
    Parameters
    Type Name Description
    string jsonContent

    The theme JSON content.

    Implements

    IDisposable
    In This Article
    Back to top
    Copyright © 2026 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)