Ingen beskrivning
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Distance.cs 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. namespace Unity.VisualScripting
  2. {
  3. [UnitOrder(402)]
  4. public abstract class Distance<T> : Unit
  5. {
  6. /// <summary>
  7. /// The first vector.
  8. /// </summary>
  9. [DoNotSerialize]
  10. public ValueInput a { get; private set; }
  11. /// <summary>
  12. /// The second vector.
  13. /// </summary>
  14. [DoNotSerialize]
  15. public ValueInput b { get; private set; }
  16. /// <summary>
  17. /// The distance between A and B.
  18. /// </summary>
  19. [DoNotSerialize]
  20. [PortLabelHidden]
  21. public ValueOutput distance { get; private set; }
  22. protected override void Definition()
  23. {
  24. a = ValueInput<T>(nameof(a));
  25. b = ValueInput<T>(nameof(b));
  26. distance = ValueOutput(nameof(distance), Operation).Predictable();
  27. Requirement(a, distance);
  28. Requirement(b, distance);
  29. }
  30. private float Operation(Flow flow)
  31. {
  32. return Operation(flow.GetValue<T>(a), flow.GetValue<T>(b));
  33. }
  34. public abstract float Operation(T a, T b);
  35. }
  36. }