using System.Collections; using System.Collections.Generic; using System.ComponentModel; #if !UNITY_WEBGL using System.Reflection; #endif using UnityEngine; /******************************************************************************** *Create By CG *Function 枚举控制 *********************************************************************************/ namespace CG.UTility { public class EnumCtrl { public enum SystemType { /// /// 缺省值 /// [Description("默认状态")] None, /// /// 安装部署 /// [Description("安装部署")] AZBS, /// /// 部件拆装 /// [Description("部件拆装")] BJCZ, /// /// 搬运 /// [Description("搬运")] BY, /// /// 视觉分拣 /// [Description("视觉分拣")] SJFJ, /// /// 焊接 /// [Description("焊接")] HJ, /// /// 喷涂 /// [Description("喷涂")] PT } public enum BJCZState { /// /// 缺省值 /// [Description("默认状态")] None, /// /// 部件认知 /// [Description("部件认知")] BJRZ, /// /// 一键拆解 /// [Description("一键拆解")] YJCJ, /// /// 一键拼装 /// [Description("一键拼装")] YJPZ, /// /// 顺序拆解 /// [Description("顺序拆解")] SXCJ, /// /// 原理示意 /// [Description("原理示意")] YLSY } public static string GetEnumDescription(System.Enum enumValue) { #if UNITY_WEBGL switch (enumValue) { case SystemType.AZBS: return "安装部署"; break; case SystemType.BJCZ: return "部件拆装"; break; case SystemType.BY: return "搬运"; break; case SystemType.SJFJ: return "视觉分拣"; break; case SystemType.HJ: return "焊接"; break; case SystemType.PT: return "喷涂"; break; default: break; } return null; #else string value = enumValue.ToString(); FieldInfo field = enumValue.GetType().GetField(value); object[] objs = field.GetCustomAttributes(typeof(DescriptionAttribute), false); if (objs == null || objs.Length == 0) { return value; } DescriptionAttribute descriptionAttribute = (DescriptionAttribute)objs[0]; return descriptionAttribute.Description; #endif } } }