Created
October 11, 2018 00:17
-
-
Save mpintar/0b6b1e259e30dbc7d55f1f43f0c1a370 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
public class EnumMaskAttribute : PropertyAttribute | |
{ | |
public EnumMaskAttribute() { } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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