QuaternionPropertyDrawer.cs 569 B

123456789101112131415161718
  1. using UnityEngine;
  2. namespace UnityEditor.Rendering
  3. {
  4. [CustomPropertyDrawer(typeof(Quaternion))]
  5. class QuaternionPropertyDrawer : PropertyDrawer
  6. {
  7. public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
  8. {
  9. var euler = property.quaternionValue.eulerAngles;
  10. EditorGUI.BeginChangeCheck();
  11. euler = EditorGUI.Vector3Field(position, label, euler);
  12. if (EditorGUI.EndChangeCheck())
  13. property.quaternionValue = Quaternion.Euler(euler);
  14. }
  15. }
  16. }