using System.Collections; using System.Collections.Generic; using UnityEngine; namespace YKMoon { public static class SystemTypeExtension { public static string GetDisplayName(this System.Type type) { var nameAttr = GetNameAttribute(type); if(nameAttr != null) { return nameAttr.DisplayName; } else { return type.Name; } } public static System.ComponentModel.DisplayNameAttribute GetNameAttribute(this System.Type type) { var attrs = type.GetCustomAttributes(typeof(System.ComponentModel.DisplayNameAttribute), true); if(attrs == null || attrs.Length == 0) { return null; } return attrs[0] as System.ComponentModel.DisplayNameAttribute; } } }