using FairyGUI; using System.Collections.Generic; namespace ET { public static class GObjectHelper { private static Dictionary _keyValuePairs = new Dictionary(); public static T Get(this GObject self) where T : FUI { if (self != null && _keyValuePairs.TryGetValue(self,out FUI ui)) { return ui as T; } return default; } public static void Add(this GObject self, FUI fui) { if (self != null && fui != null) { _keyValuePairs[self] = fui; } } public static FUI Remove(this GObject self) { if (self != null && _keyValuePairs.TryGetValue(self, out FUI ui)) { _keyValuePairs.Remove(self); return ui; } return null; } } }