Infohazard.Core 1.4.1
Infohazard Core Utility Library
Loading...
Searching...
No Matches
Infohazard.Core.Singleton< T > Class Template Reference

Base class that makes it easier to write scripts that always have exactly one instance. More...

Properties

static T Instance [get]
 Get the singleton instance of the script. More...
 

Detailed Description

Base class that makes it easier to write scripts that always have exactly one instance.

You can inherit from this script in managers or other scripts. You must still place the script on a GameObject in the scene. A static Instance accessor is automatically provided, which will do a lazy search for the correct instance the first time it is used, or if the previous instance was destroyed. After that it will just return a cached instance.

Template Parameters
TPass the name of the inheriting class here to set the type of Instance.
Type Constraints
T :SingletonBase 

Property Documentation

◆ Instance

T Infohazard.Core.Singleton< T >.Instance
staticget

Get the singleton instance of the script.

If it hasn't been found yet (or the old instance was destroyed), will do a search using Object.Find{T}. Otherwise it returns the cached instance. However, it will not create a new instance for you.


The documentation for this class was generated from the following file: