Singularity/Library/PackageCache/com.unity.visualscripting@1.../Runtime/VisualScripting.Flow/Framework/Math/Absolute.cs

36 lines
915 B
C#
Raw Normal View History

2024-05-06 14:45:45 -04:00
namespace Unity.VisualScripting
{
[UnitOrder(201)]
public abstract class Absolute<TInput> : Unit
{
/// <summary>
/// The value to make positive.
/// </summary>
[DoNotSerialize]
[PortLabelHidden]
public ValueInput input { get; private set; }
/// <summary>
/// The positive value.
/// </summary>
[DoNotSerialize]
[PortLabelHidden]
public ValueOutput output { get; private set; }
protected override void Definition()
{
input = ValueInput<TInput>(nameof(input));
output = ValueOutput(nameof(output), Operation).Predictable();
Requirement(input, output);
}
protected abstract TInput Operation(TInput input);
public TInput Operation(Flow flow)
{
return Operation(flow.GetValue<TInput>(input));
}
}
}