docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class GlobalContextManager

    Provides access to activatable platform nodes (GlobalContext<TEnum>). Contexts are auto-discovered by PlatformNodeRegistry at startup. Use Get<T>() to retrieve a context, then call Activate(Enum) to change its state.

    Inheritance
    object
    GlobalContextManager
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: UnityEngine.TestTools.Graphics
    Assembly: UnityEngine.TestTools.Graphics.dll
    Syntax
    public static class GlobalContextManager

    Methods

    AssertContextIs<T>(Enum)

    Asserts that the specified context's current value equals the expected value.

    Declaration
    public static void AssertContextIs<T>(Enum expected) where T : class, IPlatformNode
    Parameters
    Type Name Description
    Enum expected

    The expected enum value.

    Type Parameters
    Name Description
    T

    The concrete platform node type.

    AssertContextIs<TContext, TValue>(TValue)

    Asserts that the context of the specified type matches the provided value.

    Declaration
    [Obsolete("Use AssertContextIs<T>(Enum expected) instead — only one type parameter needed.")]
    public static void AssertContextIs<TContext, TValue>(TValue expected) where TContext : IGlobalContextProvider where TValue : Enum
    Parameters
    Type Name Description
    TValue expected

    The expected enum value.

    Type Parameters
    Name Description
    TContext

    The context provider type to check.

    TValue

    The enum type of the expected value.

    GetGlobalContext<TContext>()

    Retrieves the global context of the specified type.

    Declaration
    [Obsolete("Use GlobalContextManager.Get<T>() instead.")]
    public static TContext GetGlobalContext<TContext>() where TContext : IGlobalContextProvider
    Returns
    Type Description
    TContext

    The context provider instance, or the default value if not registered.

    Type Parameters
    Name Description
    TContext

    The context provider type to retrieve.

    Get<T>()

    Retrieves the singleton instance of the specified platform node type. The node must have been auto-discovered by PlatformNodeRegistry.

    Declaration
    public static T Get<T>() where T : class, IPlatformNode
    Returns
    Type Description
    T

    The singleton instance, or null if the type was not discovered.

    Type Parameters
    Name Description
    T

    The concrete platform node type.

    IsGlobalContextRegistered(Type)

    Checks if a global context of the specified type is registered.

    Declaration
    [Obsolete("Registration is no longer needed. Use GlobalContextManager.Get<T>() != null to check if a node exists.")]
    public static bool IsGlobalContextRegistered(Type contextType)
    Parameters
    Type Name Description
    Type contextType

    The type of the context to check.

    Returns
    Type Description
    bool

    True if a context of the specified type is registered; otherwise, false.

    RegisterGlobalContext(Type)

    Registers a global context of the specified type.

    Declaration
    [Obsolete("Use GlobalContextManager.Get<T>() instead. Registration is no longer needed — nodes are auto-discovered.")]
    public static IGlobalContextProvider RegisterGlobalContext(Type contextType)
    Parameters
    Type Name Description
    Type contextType

    The type of the context to register. Must implement IGlobalContextProvider.

    Returns
    Type Description
    IGlobalContextProvider

    The registered context provider instance.

    UnregisterGlobalContext(Type)

    Unregisters a global context of the specified type.

    Declaration
    [Obsolete("Unregistration is no longer needed. Just restore previous state via Activate().")]
    public static void UnregisterGlobalContext(Type contextType)
    Parameters
    Type Name Description
    Type contextType

    The type of the context to unregister.

    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)