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.
[GlobalConfig("Assets/Resources/MyConfigFiles/")]
public class MyGlobalConfig : GlobalConfig<MyGlobalConfig>
{
public int MyGlobalVariable;
}
void SomeMethod()
{
int value = MyGlobalConfig.Instance.MyGlobalVariable;
}
protected GlobalConfig()
public static GlobalConfigAttribute ConfigAttribute { get; }
public static bool HasInstanceLoaded { get; }
public static T Instance { get; }
public static void LoadInstanceIfAssetExists()
protected virtual void OnConfigAutoCreated()
protected virtual void OnConfigInstanceFirstAccessed()
public void OpenInEditor()