Skip to main content

SingletonBehaviour<T>

A class in Alta.Singletons, Alta.Utilities.

Base for a component that should exist once. The first one to wake becomes Instance; any later copy destroys itself.

Constructors​

MemberWhat it is
SingletonBehaviour()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

MemberWhat it is
static Action<T> InstanceSetCalled with the instance when it is set.

Properties​

MemberWhat it is
static T Instance { get; protected set; }The single instance, or null before one has woken.

Methods​

MemberWhat it is
protected virtual void Awake()Registers this as Instance, or destroys this component if one already exists. Call the base if you override it.