Vector4Drawer.cs 749 B

1234567891011121314151617181920212223
  1. using UnityEngine;
  2. using UnityEditor;
  3. using UnityEditor.UIElements;
  4. using UnityEngine.UIElements;
  5. namespace GraphProcessor
  6. {
  7. // We need a drawer to display Vector4 on a single line because by default it's a toggle
  8. [CustomPropertyDrawer(typeof(Vector4))]
  9. public class IngredientDrawerUIE : PropertyDrawer
  10. {
  11. public override VisualElement CreatePropertyGUI(SerializedProperty property)
  12. {
  13. var vectorField = new Vector4Field() { value = property.vector4Value };
  14. vectorField.RegisterValueChangedCallback(e => {
  15. property.vector4Value = e.newValue;
  16. property.serializedObject.ApplyModifiedProperties();
  17. });
  18. return vectorField;
  19. }
  20. }
  21. }