22 private static Dictionary<string, object> GetOrCreateRepo()
24 if (GUI.Canvas.GUIComponent is not GUIButton)
26 GUI.Canvas.GUIComponent =
new GUIButton(
new RectTransform(
new Point(0, 0)));
29 if (GUI.Canvas.GUIComponent.UserData is not Dictionary<string, object>)
31 GUI.Canvas.GUIComponent.UserData =
new Dictionary<string, object>();
34 return (Dictionary<string, object>)GUI.Canvas.GUIComponent.UserData;
37 public static object Get<TValue>(
string key) => (TValue)Get(key);
38 public static object Get(
string key)
40 Dictionary<string, object> repo = GetOrCreateRepo();
41 return repo.GetValueOrDefault(key);
43 public static void Set(
string key,
object value)
45 Dictionary<string, object> repo = GetOrCreateRepo();
48 public static bool Has(
string key)
50 Dictionary<string, object> repo = GetOrCreateRepo();
51 return repo.ContainsKey(key);