StringNodeView.cs 795 B

12345678910111213141516171819202122232425262728
  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 System.Linq;
  10. [NodeCustomEditor(typeof(StringNode))]
  11. public class StringNodeView : BaseNodeView
  12. {
  13. public override void Enable()
  14. {
  15. var node = nodeTarget as StringNode;
  16. var textArea = new TextField(-1, true, false, '*') { value = node.output };
  17. textArea.Children().First().style.unityTextAlign = TextAnchor.UpperLeft;
  18. textArea.style.width = 200;
  19. textArea.style.height = 100;
  20. textArea.RegisterValueChangedCallback(v => {
  21. owner.RegisterCompleteObjectUndo("Edit string node");
  22. node.output = v.newValue;
  23. });
  24. controlsContainer.Add(textArea);
  25. }
  26. }