Version 3.3.1.2

GlobalConfig<T> class

Namespace: Sirenix.Utilities
Assembly: Sirenix.Utilities
public abstract class GlobalConfig<T> : ScriptableObject, IGlobalConfigEvents where T : GlobalConfig<T>, new()

A GlobalConfig singleton, automatically created and saved as a ScriptableObject in the project at the specified path. This only happens if the UnityEditor is present. If it's not, a non-persistent ScriptableObject is created at run-time.

Remember to locate the path within a resources folder if you want the config file to be loaded at runtime without the Unity editor being present.

The asset path is specified by defining a GlobalConfigAttribute. If no attribute is defined it will be saved in the root assets folder.

Inheritance
  • System.Object
  • GlobalConfig<T>
Example
[GlobalConfig("Assets/Resources/MyConfigFiles/")]
public class MyGlobalConfig : GlobalConfig<MyGlobalConfig>
{
    public int MyGlobalVariable;
}

void SomeMethod()
{
    int value = MyGlobalConfig.Instance.MyGlobalVariable;
}

Type Parameters

T

Constructors

GlobalConfig()
protected GlobalConfig()

Properties

ConfigAttribute
public static GlobalConfigAttribute ConfigAttribute { get; }
HasInstanceLoaded
Gets a value indicating whether this instance has instance loaded.
public static bool HasInstanceLoaded { get; }
Instance
Gets the singleton instance.
public static T Instance { get; }

Methods

LoadInstanceIfAssetExists()
Tries to load the singleton instance.
public static void LoadInstanceIfAssetExists()
OnConfigAutoCreated()
protected virtual void OnConfigAutoCreated()
OnConfigInstanceFirstAccessed()
protected virtual void OnConfigInstanceFirstAccessed()
OpenInEditor()
Opens the config in a editor window. This is currently only used internally by the Sirenix.OdinInspector.Editor assembly.
public void OpenInEditor()