No Description
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.

Minimum.cs 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using System.Collections.Generic;
  2. using System.Linq;
  3. namespace Unity.VisualScripting
  4. {
  5. [UnitOrder(301)]
  6. public abstract class Minimum<T> : MultiInputUnit<T>
  7. {
  8. /// <summary>
  9. /// The minimum.
  10. /// </summary>
  11. [DoNotSerialize]
  12. [PortLabelHidden]
  13. public ValueOutput minimum { get; private set; }
  14. protected override void Definition()
  15. {
  16. base.Definition();
  17. minimum = ValueOutput(nameof(minimum), Operation).Predictable();
  18. foreach (var multiInput in multiInputs)
  19. {
  20. Requirement(multiInput, minimum);
  21. }
  22. }
  23. public abstract T Operation(T a, T b);
  24. public abstract T Operation(IEnumerable<T> values);
  25. public T Operation(Flow flow)
  26. {
  27. if (inputCount == 2)
  28. {
  29. return Operation(flow.GetValue<T>(multiInputs[0]), flow.GetValue<T>(multiInputs[1]));
  30. }
  31. else
  32. {
  33. return Operation(multiInputs.Select(flow.GetValue<T>));
  34. }
  35. }
  36. }
  37. }