FloatNodeView.cs 739 B

12345678910111213141516171819202122232425262728293031
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEditor;
  5. using UnityEditor.UIElements;
  6. using UnityEditor.Experimental.GraphView;
  7. using UnityEngine.UIElements;
  8. using GraphProcessor;
  9. [NodeCustomEditor(typeof(FloatNode))]
  10. public class FloatNodeView : BaseNodeView
  11. {
  12. public override void Enable()
  13. {
  14. var floatNode = nodeTarget as FloatNode;
  15. DoubleField floatField = new DoubleField
  16. {
  17. value = floatNode.input
  18. };
  19. floatNode.onProcessed += () => floatField.value = floatNode.input;
  20. floatField.RegisterValueChangedCallback((v) => {
  21. owner.RegisterCompleteObjectUndo("Updated floatNode input");
  22. floatNode.input = (float)v.newValue;
  23. });
  24. controlsContainer.Add(floatField);
  25. }
  26. }