Renamed all attributes and drawers to have postfix of either Attribute or AttributeDrawer
This commit is contained in:
parent
81bac32538
commit
dc15bfec81
161 changed files with 265 additions and 265 deletions
33
Editor/Drawers/EnumFlagAttributeDrawer.cs
Normal file
33
Editor/Drawers/EnumFlagAttributeDrawer.cs
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
using System;
|
||||
using Module.Inspector.Editor.Utilities;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Module.Inspector.Editor
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(EnumFlagAttribute))]
|
||||
internal sealed class EnumFlagAttributeDrawer : DrawerPropertyDrawer
|
||||
{
|
||||
public override bool Draw(Rect position, DrawerPropertyAttribute attribute, SerializedProperty property, GUIContent label, EditorPropertyUtility.Result result)
|
||||
{
|
||||
if (property.propertyType != SerializedPropertyType.Enum)
|
||||
return false;
|
||||
|
||||
Type type = property.GetValueType();
|
||||
|
||||
EditorGUI.BeginProperty(position, label, property);
|
||||
{
|
||||
var e = (Enum)Enum.ToObject(type, property.intValue);
|
||||
e = EditorGUI.EnumFlagsField(position, label, e);
|
||||
property.intValue = Convert.ToInt32(e);
|
||||
}
|
||||
EditorGUI.EndProperty();
|
||||
return true;
|
||||
}
|
||||
|
||||
public override string GetErrorMessage(SerializedProperty property)
|
||||
{
|
||||
return "Only supports enum";
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue