docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class TextMateSyntaxHighlighter

    Converts source code to UITK rich text using TextMate grammars and themes. Uses themed/encoded tokenization for optimal performance in static display.

    Inheritance
    object
    TextMateSyntaxHighlighter
    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.UI
    Assembly: Unity.AppUI.dll
    Syntax
    public class TextMateSyntaxHighlighter : IDisposable

    Constructors

    TextMateSyntaxHighlighter(TextMateGrammarAsset, TextMateThemeAsset)

    Creates a new syntax highlighter with the specified grammar and theme.

    Declaration
    public TextMateSyntaxHighlighter(TextMateGrammarAsset grammarAsset, TextMateThemeAsset themeAsset)
    Parameters
    Type Name Description
    TextMateGrammarAsset grammarAsset

    The TextMate grammar asset for tokenization.

    TextMateThemeAsset themeAsset

    The TextMate theme asset for colors and styles.

    Exceptions
    Type Condition
    ArgumentNullException

    Thrown when grammarAsset or themeAsset is null.

    InvalidOperationException

    Thrown when grammar or theme fails to load.

    Properties

    defaultBackground

    Gets the default background color in RGBA format (0xRRGGBBAA).

    Declaration
    public uint defaultBackground { get; }
    Property Value
    Type Description
    uint

    defaultForeground

    Gets the default foreground color in RGBA format (0xRRGGBBAA).

    Declaration
    public uint defaultForeground { get; }
    Property Value
    Type Description
    uint

    grammar

    The TextMate grammar used for tokenization.

    Declaration
    public Grammar grammar { get; }
    Property Value
    Type Description
    Grammar

    registry

    The TextMate registry used by this highlighter.

    Declaration
    public Registry registry { get; }
    Property Value
    Type Description
    Registry

    Methods

    Dispose()

    Releases the native resources used by the highlighter.

    Declaration
    public void Dispose()

    ~TextMateSyntaxHighlighter()

    Finalizer to ensure resources are released.

    Declaration
    protected ~TextMateSyntaxHighlighter()

    Highlight(string)

    Highlights source code and returns UITK-compatible rich text. Uses batch themed tokenization for optimal performance.

    Declaration
    public string Highlight(string sourceCode)
    Parameters
    Type Name Description
    string sourceCode

    The source code to highlight.

    Returns
    Type Description
    string

    Rich text string with UITK color and style tags.

    HighlightLine(string, IntPtr, out IntPtr)

    Highlights a single line of code.

    Declaration
    public string HighlightLine(string line, IntPtr prevState, out IntPtr newState)
    Parameters
    Type Name Description
    string line

    The line to highlight.

    IntPtr prevState

    The state from the previous line (use IntPtr.Zero for the first line).

    IntPtr newState

    The state at the end of this line, to be passed to the next line.

    Returns
    Type Description
    string

    Rich text string for the line.

    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)