using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Reflection; #if ODIN_INSPECTOR using Sirenix.OdinInspector; #endif using UnityEngine; using XericLibrary.Runtime.MacroLibrary; using Object = UnityEngine.Object; namespace XericUI.ReflectionUIGenerator { /// /// [已弃用] 属性映射器。请使用 XuiavrgPropertyGroupScriptableObject 替代。 /// 功能已整合到 PropertyGroup 中,此类保留仅用于向后兼容。 /// [Serializable] [Obsolete("Use XuiavrgPropertyGroupScriptableObject instead. Property mapping is now integrated directly into the group.")] public class XuiavrPropertyScriptableObject : ScriptableObject { #if ODIN_INSPECTOR [LabelText("属性类型")] [ValueDropdown("AssemblyValueTypeNames")] #endif public string valueType; #if ODIN_INSPECTOR [LabelText("属性名称")] #endif public string propertyName; #if ODIN_INSPECTOR [LabelText("界面预制体")] #endif public GameObject prefab; /// /// 属性类型 /// public System.Type ValueType { get { if (_valueType != null) return _valueType; return _valueType = Type.GetType(valueType); } } private System.Type _valueType; #if ODIN_INSPECTOR // 属性类型名称枚举 private IEnumerable AssemblyValueTypeNames { get { if (_assemblyValueTypeName != null) return _assemblyValueTypeName; _assemblyValueTypeName = new ValueDropdownList(); // foreach (var typeName in MacroReflection.GetAllAssignableTypeInAppDomainAssembly( // typeof(float), // typeof(string), // typeof(bool), // typeof(Enum), // typeof(int) // ).Select(a => a.FullName)) // { // _assemblyValueTypeName.Add(typeName); // } _assemblyValueTypeName.AddRange(AllValueType.Select(a => new ValueDropdownItem(a.Name, a.FullName))); return _assemblyValueTypeName; } } private static ValueDropdownList _assemblyValueTypeName = null; #endif /// /// 直接定义所有需要检查的类型 /// public static IEnumerable AllValueType { get { yield return typeof(Enum); yield return typeof(decimal); yield return typeof(double); yield return typeof(float); yield return typeof(ulong); yield return typeof(long); yield return typeof(int); yield return typeof(uint); yield return typeof(short); yield return typeof(ushort); yield return typeof(byte); yield return typeof(sbyte); yield return typeof(string); yield return typeof(char); yield return typeof(bool); } } } }