Renamed all attributes and drawers to have postfix of either Attribute or AttributeDrawer

This commit is contained in:
Anders Ejlersen 2021-12-04 12:47:44 +01:00
parent 81bac32538
commit dc15bfec81
161 changed files with 265 additions and 265 deletions

View file

@ -0,0 +1,36 @@
using Module.Inspector.Editor.Utilities;
using UnityEditor;
using UnityEngine;
namespace Module.Inspector.Editor
{
[CustomPropertyDrawer(typeof(QuaternionToEulerAttribute))]
internal sealed class QuaternionToEulerAttributeDrawer : DrawerPropertyDrawer
{
public override bool Draw(Rect position, DrawerPropertyAttribute attribute, SerializedProperty property, GUIContent label, EditorPropertyUtility.Result result)
{
if (property.propertyType != SerializedPropertyType.Quaternion)
return false;
EditorGUI.BeginChangeCheck();
EditorGUI.BeginProperty(position, label, property);
{
Vector3 euler = property.quaternionValue.eulerAngles;
Vector3 temp = EditorGUI.Vector3Field(position, label, euler);
property.quaternionValue = Quaternion.Euler(temp);
}
EditorGUI.EndProperty();
bool changed = EditorGUI.EndChangeCheck();
if (changed)
property.serializedObject.ApplyModifiedProperties();
return true;
}
public override string GetErrorMessage(SerializedProperty property)
{
return "Only supports quaternions";
}
}
}