and for flags to work properly they would need to be as followed
enum MyFlags
{
a = 1, //1
b =2 , //2
c = 4, //4
e = 8, //8
}
But I too find it annoying there is no default way to draw a lot of things which unity has methods for drawing, flags being one of them. It annoys me more that the EditorGUI.MaskField shows ‘mixed’ when two values are selected, rather than how it works on say LayerMasks showing up to 3 selected values before it goes mixed.
just fyi, this is how we draw the mask field for anybody that is curious
public override void OnGUI(Rect position,
SerializedProperty property,
GUIContent label)
{
EditorGUI.BeginChangeCheck();
uint a = (uint)(EditorGUI.MaskField(position, label, property.intValue, property.enumNames));
if (EditorGUI.EndChangeCheck())
{
property.intValue = (int)a;
}
}
@BinaryCats Not really, flag could be define as 0,1,2,3 if the person who create it know what they really want to do
In fact the person who create enum with [flags] would really have knowledge about how to define enum value. So it’s their responsible to define enum value properly
It just that unity should be responsible for drawing all enum with [flags] by EnumFlagsField (and normal enum by EnumPopup) by default