Unity默认的枚举值不支持数字开头,也不支持汉字;而且只能显示全部的枚举项,无法只显示部分选项
新建脚本EnumTest,代码如下
using System.Collections; using System.Collections.Generic; using UnityEngine; public class EnumTest : MonoBehaviour { public EAttackLevel level; } public enum EAttackLevel { None, Low, Med, High, }
①我想不显示None选项
②我想枚举选项以数字开头
③我想枚举选项显示汉语
使用CustomPropertyDrawer以上需求都可以:
新建脚本EnumAttackLevelAttribute:
1 using System.Collections.Generic; 2 using UnityEditor; 3 using UnityEngine; 4 5