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.

Multiply.cs 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. namespace Unity.VisualScripting
  2. {
  3. [UnitOrder(103)]
  4. public abstract class Multiply<T> : Unit
  5. {
  6. /// <summary>
  7. /// The first value.
  8. /// </summary>
  9. [DoNotSerialize]
  10. public ValueInput a { get; private set; }
  11. /// <summary>
  12. /// The second value.
  13. /// </summary>
  14. [DoNotSerialize]
  15. public ValueInput b { get; private set; }
  16. /// <summary>
  17. /// The product of A and B.
  18. /// </summary>
  19. [DoNotSerialize]
  20. [PortLabel("A \u00D7 B")]
  21. public ValueOutput product { get; private set; }
  22. [DoNotSerialize]
  23. protected virtual T defaultB => default(T);
  24. protected override void Definition()
  25. {
  26. a = ValueInput<T>(nameof(a));
  27. b = ValueInput(nameof(b), defaultB);
  28. product = ValueOutput(nameof(product), Operation).Predictable();
  29. Requirement(a, product);
  30. Requirement(b, product);
  31. }
  32. private T Operation(Flow flow)
  33. {
  34. return Operation(flow.GetValue<T>(a), flow.GetValue<T>(b));
  35. }
  36. public abstract T Operation(T a, T b);
  37. }
  38. }