IMotionAdapter<TValue, TOptions>
独自のunmanaged値型用の補間を定義します。Evaluateには始点・終点、オプション、イーズ適用後の進捗と時刻が渡されます。
public interface IMotionAdapter<TValue, TOptions>
where TValue : unmanaged
where TOptions : unmanaged, IMotionOptionsIMotionAdapter.cs · L21途中で切り替わる補間を定義する
using MeatMotion; を追加します。次の型をメソッドの外に定義し、呼び出し例はメソッド内に置きます。イーズ適用後の進捗が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;
メンバー
Evaluate
始点・終点、オプション、時刻を受けて現在値を返します。値の書き込みはバインド先が行います。
TValue Evaluate(ref TValue startValue, ref TValue endValue, ref TOptions options, in MotionEvaluationContext context)引数と戻り値
startValueref TValue補間の開始値。endValueref TValue補間の終了値。optionsref TOptionsこの値型のアダプターに渡す設定。contextin MotionEvaluationContextイーズ適用後のProgressと経過秒数Time。- 戻り値
TValue
MeatMotion