GlobalConfig<T>

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.

namespace Sirenix.Utilities
{
public abstract class GlobalConfig<T> : UnityEngine.ScriptableObject
where T : GlobalConfig<T>
}

Requirements

Namespace: Sirenix.Utilities
Assembly: Sirenix.OdinInspector
Version: 2.0.0.0

Static Properties

Return Type Definition Description
bool HasInstanceLoaded Gets a value indicating whether this instance has instance loaded.
T Instance Gets the singleton instance.

Static Methods

Return Type Definition Description
void LoadInstanceIfAssetExists() Tries to load the singleton instance.

Methods

Return Type Definition Description
void OpenInEditor() Opens the config in a editor window. This is currently only used internally by the Sirenix.OdinInspector.Editor assembly.

Example

[GlobalConfig("Resources/MyConfigFiles/")]
public class MyGlobalConfig : GlobalConfig<MyGlobalConfig>
{
    public int MyGlobalVariable;
}

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