Class GlobalScope
Static runtime registry and service locator for globally accessible UnityEngine.Component instances. Stores one registration per concrete component type and is intended for Play Mode usage.
public static class GlobalScope
- Inheritance
-
objectGlobalScope
Methods
Clear()
Remove all registered global instances. Only valid in Play Mode.
public static void Clear()
GetComponent<T>()
Get the registered global instance of type T. Returns null if not registered.
public static T GetComponent<T>() where T : Component
Returns
- T
Type Parameters
T
IsRegistered<T>()
Returns true if a global instance of type T is registered.
public static bool IsRegistered<T>() where T : Component
Returns
- bool
Type Parameters
T
RegisterComponent(Component, Object)
Register a global instance. Only valid in Play Mode. Only one instance per type.
public static void RegisterComponent(Component instance, Object caller)
Parameters
instanceComponentcallerObject
TryGetComponent<T>(out T)
public static bool TryGetComponent<T>(out T component) where T : Component
Parameters
componentT
Returns
- bool
Type Parameters
T
UnregisterComponent(Component, Object)
Unregister a global instance. Only valid in Play Mode.
public static void UnregisterComponent(Component instance, Object caller)
Parameters
instanceComponentcallerObject