1.6.0: Added FieldLabelFromType, StringToAnimationClipName and SingleSelectionFlag

This commit is contained in:
Anders Ejlersen 2022-07-09 23:30:15 +02:00
parent 7d99d62e11
commit 9faacb6291
15 changed files with 215 additions and 6 deletions

View file

@ -0,0 +1,28 @@
using Module.Inspector.Editor.Utilities;
using UnityEditor;
using UnityEngine;
namespace Module.Inspector.Editor
{
[CustomPropertyDrawer(typeof(SingleSelectionFlagAttribute))]
internal sealed class SingleSelectionFlagAttributeDrawer : DrawerPropertyDrawer
{
public override bool Draw(Rect position, DrawerPropertyAttribute attribute, SerializedProperty property, GUIContent label, EditorPropertyUtility.Result result)
{
if (property.propertyType != SerializedPropertyType.Enum)
return false;
EditorGUI.BeginProperty(position, label, property);
{
property.enumValueIndex = EditorGUI.Popup(position, label.text, property.enumValueIndex, property.enumDisplayNames);
}
EditorGUI.EndProperty();
return true;
}
public override string GetErrorMessage(SerializedProperty property)
{
return "Only supports enum";
}
}
}