namespace Unity.VisualScripting { [UnitOrder(101)] public abstract class Add : Unit { /// /// The first value. /// [DoNotSerialize] public ValueInput a { get; private set; } /// /// The second value. /// [DoNotSerialize] public ValueInput b { get; private set; } /// /// The sum of A and B. /// [DoNotSerialize] [PortLabel("A + B")] public ValueOutput sum { get; private set; } [DoNotSerialize] protected virtual T defaultB => default(T); protected override void Definition() { a = ValueInput(nameof(a)); b = ValueInput(nameof(b), defaultB); sum = ValueOutput(nameof(sum), Operation).Predictable(); Requirement(a, sum); Requirement(b, sum); } private T Operation(Flow flow) { return Operation(flow.GetValue(a), flow.GetValue(b)); } public abstract T Operation(T a, T b); } }