暂无描述
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

GraphOutput.cs 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using System.Linq;
  2. namespace Unity.VisualScripting
  3. {
  4. /// <summary>
  5. /// Passes output values from this graph to the parent super unit.
  6. /// </summary>
  7. [UnitCategory("Nesting")]
  8. [UnitOrder(2)]
  9. [UnitTitle("Output")]
  10. public sealed class GraphOutput : Unit
  11. {
  12. public override bool canDefine => graph != null;
  13. protected override void Definition()
  14. {
  15. isControlRoot = true;
  16. foreach (var controlOutputDefinition in graph.validPortDefinitions.OfType<ControlOutputDefinition>())
  17. {
  18. var key = controlOutputDefinition.key;
  19. ControlInput(key, (flow) =>
  20. {
  21. var superUnit = flow.stack.GetParent<SubgraphUnit>();
  22. flow.stack.ExitParentElement();
  23. superUnit.EnsureDefined();
  24. return superUnit.controlOutputs[key];
  25. });
  26. }
  27. foreach (var valueOutputDefinition in graph.validPortDefinitions.OfType<ValueOutputDefinition>())
  28. {
  29. var key = valueOutputDefinition.key;
  30. var type = valueOutputDefinition.type;
  31. ValueInput(type, key);
  32. }
  33. }
  34. protected override void AfterDefine()
  35. {
  36. graph.onPortDefinitionsChanged += Define;
  37. }
  38. protected override void BeforeUndefine()
  39. {
  40. graph.onPortDefinitionsChanged -= Define;
  41. }
  42. }
  43. }