Skip to content

Instantly share code, notes, and snippets.

@mpintar
Created October 11, 2018 00:17
Show Gist options
  • Save mpintar/0b6b1e259e30dbc7d55f1f43f0c1a370 to your computer and use it in GitHub Desktop.
Save mpintar/0b6b1e259e30dbc7d55f1f43f0c1a370 to your computer and use it in GitHub Desktop.
using UnityEngine;
public class EnumMaskAttribute : PropertyAttribute
{
public EnumMaskAttribute() { }
}
using UnityEditor;
using UnityEngine;
[CustomPropertyDrawer(typeof(EnumMaskAttribute))]
public class EnumMaskDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
EditorGUI.BeginChangeCheck();
int value = EditorGUI.MaskField(position, label, property.intValue, property.enumNames);
if (EditorGUI.EndChangeCheck())
{
property.intValue = value;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment