Version 2.1.0.0

GlobalConfig<T> class

Namespace: Sirenix.Utilities
Assembly: Sirenix.Utilities
public abstract class GlobalConfig<T> : ScriptableObject 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("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

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()
OpenInEditor()
Opens the config in a editor window. This is currently only used internally by the Sirenix.OdinInspector.Editor assembly.
public void OpenInEditor()