MotionBuilder<TValue, TOptions, TAdapter>
値型、オプション、アダプターを持つビルダーです。イーズ、ループ、通知、更新タイミングを設定し、Bindで登録します。
public struct MotionBuilder<TValue, TOptions, TAdapter> : IDisposable
where TValue : unmanaged
where TOptions : unmanaged, IMotionOptions
where TAdapter : unmanaged, IMotionAdapter<TValue, TOptions>MotionBuilder.cs · L11設定を保存して2回使う
using MeatMotion; を追加します。Bindの前に設定を取り出せば、ハンドルの寿命が独立したTweenをいくつでも作れます。
using var world = new MotionWorld();
using var builder = MMotion.Create(0f, 10f, 1f).WithScheduler(world).AsMotionBuilder();
var settings = builder.ToMotionSettings();
float a = 0f, b = 0f;
var first = MMotion.Create(settings).Bind(v => a = v);
MMotion.Create(settings).Bind(v => b = v);
first.Cancel();
world.Tick(0.5);
メンバー
- ToMotionSettings
- Dispose
- WithScheduler
- WithEase
- WithLoops
- WithDelay
- WithImmediateBind
- WithOnCancel
- WithDebugName
- WithOnComplete
- WithOnLoopComplete
- WithOptions
- WithCancelOnError
- Bind
- RunWithoutBinding
ToMotionSettings
Bindする前に現在の設定をレコードへ取り出し、後からMMotion.Createに渡して再利用できます。
public MotionSettings<TValue, TOptions> ToMotionSettings()Dispose
ビルダーの共有バッファを返却します。構造体のコピーも同時に無効になるため、以降の設定やBindには新しいビルダーを使います。
public void Dispose()WithScheduler
Tweenを自動更新フェーズまたは手動のMotionWorldに登録します。Bindより前に指定します。
public MotionBuilder<TValue, TOptions, TAdapter> WithScheduler(MotionWorld world)引数と戻り値
worldMotionWorldこのTweenを登録するMotionWorld。- 戻り値
MotionBuilder<TValue, TOptions, TAdapter>
public MotionBuilder<TValue, TOptions, TAdapter> WithScheduler(IMotionScheduler scheduler)引数と戻り値
schedulerIMotionScheduler更新の時刻・登録先を決めるスケジューラ。- 戻り値
MotionBuilder<TValue, TOptions, TAdapter>
WithEase
正規化した時間を進捗に変換する曲線を選びます。AnimationCurveを指定してBindすると、その時点のカーブを複製して使います。
public MotionBuilder<TValue, TOptions, TAdapter> WithEase(Easing easing)引数と戻り値
easingEasing正規化時間を進捗に変換するイーズ。- 戻り値
MotionBuilder<TValue, TOptions, TAdapter>
public MotionBuilder<TValue, TOptions, TAdapter> WithEase(Ease ease)引数と戻り値
easeEase正規化時間を進捗に変換するイーズ。- 戻り値
MotionBuilder<TValue, TOptions, TAdapter>
public MotionBuilder<TValue, TOptions, TAdapter> WithEase(AnimationCurve animationCurve)引数と戻り値
animationCurveAnimationCurveカーブのキーと前後のWrapModeを含むUnityのAnimationCurve。- 戻り値
MotionBuilder<TValue, TOptions, TAdapter>
WithLoops
繰り返し回数とLoopTypeを設定します。無限ループはキャンセルで停止します。
public MotionBuilder<TValue, TOptions, TAdapter> WithLoops(int loops, LoopType loopType = LoopType.Restart)引数と戻り値
loopsintループ回数。無限ループには-1を指定できます。loopType = LoopType.RestartLoopType各ループで進捗をどの方向に評価するか。- 戻り値
MotionBuilder<TValue, TOptions, TAdapter>
WithDelay
秒単位の遅延と適用するループを設定します。skipValuesDuringDelayで遅延中の書き込みを制御します。
public MotionBuilder<TValue, TOptions, TAdapter> WithDelay(float delay, DelayType delayType = DelayType.FirstLoop, bool skipValuesDuringDelay = true)引数と戻り値
delayfloat補間の前に待つ秒数。delayType = DelayType.FirstLoopDelayType初回だけ遅延するか、各ループで遅延するか。skipValuesDuringDelay = truebool遅延区間の更新でsetterへの書き込みを抑止するか。- 戻り値
MotionBuilder<TValue, TOptions, TAdapter>
WithImmediateBind
falseを指定するとBind時の初回の書き込みを抑止します。カスタムカーブでは初回の値にカーブの始点が反映されます。同じプロパティを後で書き換える子Tweenに使えます。
public MotionBuilder<TValue, TOptions, TAdapter> WithImmediateBind(bool immediateBind = true)引数と戻り値
immediateBind = trueboolBindした時点で開始値を書き込むかを指定します。- 戻り値
MotionBuilder<TValue, TOptions, TAdapter>
WithOnCancel
キャンセル時に呼ぶ処理を登録します。
public MotionBuilder<TValue, TOptions, TAdapter> WithOnCancel(Action callback)引数と戻り値
callbackActionキャンセル時に呼ぶ処理を登録します。- 戻り値
MotionBuilder<TValue, TOptions, TAdapter>
WithDebugName
EditorやDevelopment BuildでTweenを識別する名前を指定します。
public MotionBuilder<TValue, TOptions, TAdapter> WithDebugName(string debugName)引数と戻り値
debugNamestringEditorなどでTweenを識別する名前。- 戻り値
MotionBuilder<TValue, TOptions, TAdapter>
WithOnComplete
終端に達したとき、または明示的に完了したときに呼ぶ処理を登録します。
public MotionBuilder<TValue, TOptions, TAdapter> WithOnComplete(Action callback)引数と戻り値
callbackAction終端に達したとき、または明示的に完了したときに呼ぶ処理を登録します。- 戻り値
MotionBuilder<TValue, TOptions, TAdapter>
WithOnLoopComplete
ループ境界を通過したときに、完了したループ数を受け取るコールバックを登録します。
public MotionBuilder<TValue, TOptions, TAdapter> WithOnLoopComplete(Action<int> callback)引数と戻り値
callbackAction<int>ループ境界を通過したときに、完了したループ数を受け取るコールバックを登録します。- 戻り値
MotionBuilder<TValue, TOptions, TAdapter>
WithOptions
補間に使うオプション構造体を設定します。
public MotionBuilder<TValue, TOptions, TAdapter> WithOptions(TOptions options)引数と戻り値
optionsTOptionsこの値型のアダプターに渡す設定。- 戻り値
MotionBuilder<TValue, TOptions, TAdapter>
WithCancelOnError
setterが例外を投げた場合に、そのTweenをキャンセルするか指定します。
public MotionBuilder<TValue, TOptions, TAdapter> WithCancelOnError(bool cancelOnError = true)引数と戻り値
cancelOnError = trueboolsetterが例外を投げたときにTweenをキャンセルするか。- 戻り値
MotionBuilder<TValue, TOptions, TAdapter>
Bind
補間値を書き込むsetterを登録して再生を開始します。状態付きの形式では、値に続いて登録時の状態が引数に渡されます。
public MotionHandle Bind(Action<TValue> action)引数と戻り値
actionAction<TValue>補間した値を受け取る処理。- 戻り値
MotionHandle
public MotionHandle Bind<T1>(T1 state, Action<TValue, T1> action)
where T1 : class引数と戻り値
stateT1setterの呼び出し時に補間値に続けて渡す状態。actionAction<TValue, T1>補間した値を受け取る処理。- 戻り値
MotionHandle
public MotionHandle Bind<T1, T2>(T1 state0, T2 state1, Action<TValue, T1, T2> action)
where T1 : class
where T2 : class引数と戻り値
state0T1setterの呼び出し時に補間値に続けて渡す状態。state1T2setterの呼び出し時に補間値に続けて渡す状態。actionAction<TValue, T1, T2>補間した値を受け取る処理。- 戻り値
MotionHandle
public MotionHandle Bind<T1, T2, T3>(T1 state0, T2 state1, T3 state2, Action<TValue, T1, T2, T3> action)
where T1 : class
where T2 : class
where T3 : class引数と戻り値
state0T1setterの呼び出し時に補間値に続けて渡す状態。state1T2setterの呼び出し時に補間値に続けて渡す状態。state2T3setterの呼び出し時に補間値に続けて渡す状態。actionAction<TValue, T1, T2, T3>補間した値を受け取る処理。- 戻り値
MotionHandle
RunWithoutBinding
値を書き込むsetterを渡さずに再生し、時間制御や通知に使えるハンドルを返します。
関連する型
- MMotion
- MotionBuilderExtensions
- MotionHandle
- AudioMotionExtensions
- CameraMotionExtensions
- LoggerMotionExtensions
- MaterialMotionExtensions
- ProgressMotionExtensions
- RectTransformMotionExtensions
- Rigidbody2DMotionExtensions
- RigidbodyMotionExtensions
- SpriteRendererMotionExtensions
- TextMeshProMotionExtensions
- TransformMotionExtensions
- UGUIMotionExtensions
- UIToolkitMotionExtensions
- VisualEffectMotionExtensions
- VolumeMotionExtensions
- R3MotionExtensions
- UniRxMotionExtensions
- UniTaskMotionExtensions
MeatMotion