PrintNodeView.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. using Unity.Jobs;
  10. [NodeCustomEditor(typeof(PrintNode))]
  11. public class PrintNodeView : BaseNodeView
  12. {
  13. Label printLabel;
  14. PrintNode printNode;
  15. public override void Enable()
  16. {
  17. printNode = nodeTarget as PrintNode;
  18. printLabel = new Label();
  19. controlsContainer.Add(printLabel);
  20. nodeTarget.onProcessed += UpdatePrintLabel;
  21. onPortConnected += (p) => UpdatePrintLabel();
  22. onPortDisconnected += (p) => UpdatePrintLabel();
  23. UpdatePrintLabel();
  24. }
  25. void UpdatePrintLabel()
  26. {
  27. if (printNode.obj != null)
  28. printLabel.text = printNode.obj.ToString();
  29. else
  30. printLabel.text = "null";
  31. }
  32. }
  33. [NodeCustomEditor(typeof(ConditionalPrintNode))]
  34. public class ConditionalPrintNodeView : BaseNodeView
  35. {
  36. Label printLabel;
  37. ConditionalPrintNode printNode;
  38. public override void Enable()
  39. {
  40. printNode = nodeTarget as ConditionalPrintNode;
  41. printLabel = new Label();
  42. controlsContainer.Add(printLabel);
  43. nodeTarget.onProcessed += UpdatePrintLabel;
  44. onPortConnected += (p) => UpdatePrintLabel();
  45. onPortDisconnected += (p) => UpdatePrintLabel();
  46. UpdatePrintLabel();
  47. }
  48. void UpdatePrintLabel()
  49. {
  50. if (printNode.obj != null)
  51. printLabel.text = printNode.obj.ToString();
  52. else
  53. printLabel.text = "null";
  54. }
  55. }