namespace Unity.VisualScripting { [UnitOrder(501)] public abstract class Lerp : Unit { /// /// The first value. /// [DoNotSerialize] public ValueInput a { get; private set; } /// /// The second value. /// [DoNotSerialize] public ValueInput b { get; private set; } /// /// The interpolation value. /// [DoNotSerialize] public ValueInput t { get; private set; } /// /// The linear interpolation between A and B at T. /// [DoNotSerialize] [PortLabelHidden] public ValueOutput interpolation { get; private set; } [DoNotSerialize] protected virtual T defaultA => default(T); [DoNotSerialize] protected virtual T defaultB => default(T); protected override void Definition() { a = ValueInput(nameof(a), defaultA); b = ValueInput(nameof(b), defaultB); t = ValueInput(nameof(t), 0); interpolation = ValueOutput(nameof(interpolation), Operation).Predictable(); Requirement(a, interpolation); Requirement(b, interpolation); Requirement(t, interpolation); } private T Operation(Flow flow) { return Operation(flow.GetValue(a), flow.GetValue(b), flow.GetValue(t)); } public abstract T Operation(T a, T b, float t); } }