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

Base class that makes it easier to write ScriptableObjects that always have exactly one instance in your project. More...

Properties

static T Instance [get]
 Get the singleton instance of the script. More...
 
- Properties inherited from Infohazard.Core.SingletonAssetBase
abstract string ResourceFolderPath [get]
 Return the path at which the Resources folder containing this asset lives. More...
 
abstract string ResourcePath [get]
 Returns the path of this asset relative to its Resources folder. More...
 

Detailed Description

Base class that makes it easier to write ScriptableObjects that always have exactly one instance in your project.

Similar to Singleton, but for ScriptableObjects. You specify a path in your subclass where the instance should live (this must be under a Resources folder) and the editor will automatically handle loading and even creating this asset for you when needed.

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

Property Documentation

◆ Instance

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

Get the singleton instance of the script.

If it hasn't been loaded yet, will try to load from SingletonAssetBase.ResourcePath. If in the editor and the asset doesn't exist, it will be created at SingletonAssetBase.ResourceFolderPath/SingletonAssetBase.ResourcePath. Otherwise, the cached instance (or null) will be returned.


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