using System.Collections.Generic; using XGame.Framework.UI; namespace FL.FGUI { public static partial class UINestedKeys { private static Dictionary _nameToKeys; public static UIKey NameToKey(string uiName) { if (_nameToKeys == null) { _nameToKeys = new Dictionary(); } if (_nameToKeys.TryGetValue(uiName, out UIKey key)) { return key; } var property = typeof(UIKeys).GetProperty(uiName, System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.IgnoreCase); if (property != null) { key = property.GetValue(null) as UIKey; _nameToKeys.Add(uiName, key); return key; } XGame.Log.Error($"找不到UINestedKey. uiName:{uiName}"); return default; } public static void Dispose() { _nameToKeys?.Clear(); _nameToKeys = null; } } }