Files
PrinceOfGlory/Assets/Asset Usage Finder/Editor/Data/Globals.cs
2026-03-03 18:24:17 +08:00

21 lines
500 B
C#

using System;
namespace AssetUsageFinder {
static class Globals<T> where T : class {
static T _instance;
public static void TryInit(Func<T> ctor) {
if (_instance != null) return;
_instance = ctor.Invoke();
}
public static T Get() => _instance;
public static T GetOrCreate(Func<T> ctor) {
TryInit(ctor);
return _instance;
}
public static void Set(T value) => _instance = value;
}
}