IMotionAdapter<TValue, TOptions>
Define interpolation for an unmanaged value type. Evaluate receives endpoints, options, eased progress and motion time.
public interface IMotionAdapter<TValue, TOptions>
where TValue : unmanaged
where TOptions : unmanaged, IMotionOptionsIMotionAdapter.cs · L21Define a step adapter
Add using MeatMotion;. Declare the adapter outside the calling method. Its value switches to the endpoint once eased progress reaches 0.5.
public struct StepAdapter : IMotionAdapter<float, NoOptions>
{
public float Evaluate(ref float startValue, ref float endValue,
ref NoOptions options, in MotionEvaluationContext context)
{
return context.Progress < 0.5f ? startValue : endValue;
}
}
using var world = new MotionWorld();
float value = 0f;
var handle = MMotion.Create<float, NoOptions, StepAdapter>(2f, 8f, 1f)
.WithScheduler(world).Bind(v => value = v);
handle.Time = 0.25;
float before = value;
handle.Time = 0.5;
Members
Evaluate
Return the sampled value from the endpoints, options and evaluation context. The binding writes the result to the target.
TValue Evaluate(ref TValue startValue, ref TValue endValue, ref TOptions options, in MotionEvaluationContext context)Parameters and return value
startValueref TValueStarting value.endValueref TValueEnd value.optionsref TOptionsOptions passed to this value adapter.contextin MotionEvaluationContextEased Progress and elapsed Time in seconds.- Returns
TValue
MeatMotion