MeatMotion

MotionBuilder<TValue, TOptions, TAdapter>

値型、オプション、アダプターを持つビルダーです。イーズ、ループ、通知、更新タイミングを設定し、Bindで登録します。

Namespace
MeatMotion
Assembly
MeatMotion

メンバー一覧へ

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

Bindする前に現在の設定をレコードへ取り出し、後からMMotion.Createに渡して再利用できます。

public MotionSettings<TValue, TOptions> ToMotionSettings()
戻り値
戻り値
MotionSettings<TValue, TOptions>

Dispose

ビルダーの共有バッファを返却します。構造体のコピーも同時に無効になるため、以降の設定やBindには新しいビルダーを使います。

WithScheduler

Tweenを自動更新フェーズまたは手動のMotionWorldに登録します。Bindより前に指定します。

public MotionBuilder<TValue, TOptions, TAdapter> WithScheduler(MotionWorld world)
引数と戻り値
world
MotionWorld このTweenを登録するMotionWorld。
戻り値
MotionBuilder<TValue, TOptions, TAdapter>
public MotionBuilder<TValue, TOptions, TAdapter> WithScheduler(IMotionScheduler scheduler)
引数と戻り値
scheduler
IMotionScheduler 更新の時刻・登録先を決めるスケジューラ。
戻り値
MotionBuilder<TValue, TOptions, TAdapter>

WithEase

正規化した時間を進捗に変換する曲線を選びます。AnimationCurveを指定してBindすると、その時点のカーブを複製して使います。

public MotionBuilder<TValue, TOptions, TAdapter> WithEase(Easing easing)
引数と戻り値
easing
Easing 正規化時間を進捗に変換するイーズ。
戻り値
MotionBuilder<TValue, TOptions, TAdapter>
public MotionBuilder<TValue, TOptions, TAdapter> WithEase(Ease ease)
引数と戻り値
ease
Ease 正規化時間を進捗に変換するイーズ。
戻り値
MotionBuilder<TValue, TOptions, TAdapter>
public MotionBuilder<TValue, TOptions, TAdapter> WithEase(AnimationCurve animationCurve)
引数と戻り値
animationCurve
AnimationCurve カーブのキーと前後のWrapModeを含むUnityのAnimationCurve。
戻り値
MotionBuilder<TValue, TOptions, TAdapter>

WithLoops

繰り返し回数とLoopTypeを設定します。無限ループはキャンセルで停止します。

public MotionBuilder<TValue, TOptions, TAdapter> WithLoops(int loops, LoopType loopType = LoopType.Restart)
引数と戻り値
loops
int ループ回数。無限ループには-1を指定できます。
loopType = LoopType.Restart
LoopType 各ループで進捗をどの方向に評価するか。
戻り値
MotionBuilder<TValue, TOptions, TAdapter>

WithDelay

秒単位の遅延と適用するループを設定します。skipValuesDuringDelayで遅延中の書き込みを制御します。

public MotionBuilder<TValue, TOptions, TAdapter> WithDelay(float delay, DelayType delayType = DelayType.FirstLoop, bool skipValuesDuringDelay = true)
引数と戻り値
delay
float 補間の前に待つ秒数。
delayType = DelayType.FirstLoop
DelayType 初回だけ遅延するか、各ループで遅延するか。
skipValuesDuringDelay = true
bool 遅延区間の更新でsetterへの書き込みを抑止するか。
戻り値
MotionBuilder<TValue, TOptions, TAdapter>

WithImmediateBind

falseを指定するとBind時の初回の書き込みを抑止します。カスタムカーブでは初回の値にカーブの始点が反映されます。同じプロパティを後で書き換える子Tweenに使えます。

public MotionBuilder<TValue, TOptions, TAdapter> WithImmediateBind(bool immediateBind = true)
引数と戻り値
immediateBind = true
bool Bindした時点で開始値を書き込むかを指定します。
戻り値
MotionBuilder<TValue, TOptions, TAdapter>

WithOnCancel

キャンセル時に呼ぶ処理を登録します。

public MotionBuilder<TValue, TOptions, TAdapter> WithOnCancel(Action callback)
引数と戻り値
callback
Action キャンセル時に呼ぶ処理を登録します。
戻り値
MotionBuilder<TValue, TOptions, TAdapter>

WithDebugName

EditorやDevelopment BuildでTweenを識別する名前を指定します。

public MotionBuilder<TValue, TOptions, TAdapter> WithDebugName(string debugName)
引数と戻り値
debugName
string EditorなどでTweenを識別する名前。
戻り値
MotionBuilder<TValue, TOptions, TAdapter>

WithOnComplete

終端に達したとき、または明示的に完了したときに呼ぶ処理を登録します。

public MotionBuilder<TValue, TOptions, TAdapter> WithOnComplete(Action callback)
引数と戻り値
callback
Action 終端に達したとき、または明示的に完了したときに呼ぶ処理を登録します。
戻り値
MotionBuilder<TValue, TOptions, TAdapter>

WithOnLoopComplete

ループ境界を通過したときに、完了したループ数を受け取るコールバックを登録します。

public MotionBuilder<TValue, TOptions, TAdapter> WithOnLoopComplete(Action<int> callback)
引数と戻り値
callback
Action<int> ループ境界を通過したときに、完了したループ数を受け取るコールバックを登録します。
戻り値
MotionBuilder<TValue, TOptions, TAdapter>

WithOptions

補間に使うオプション構造体を設定します。

public MotionBuilder<TValue, TOptions, TAdapter> WithOptions(TOptions options)
引数と戻り値
options
TOptions この値型のアダプターに渡す設定。
戻り値
MotionBuilder<TValue, TOptions, TAdapter>

WithCancelOnError

setterが例外を投げた場合に、そのTweenをキャンセルするか指定します。

public MotionBuilder<TValue, TOptions, TAdapter> WithCancelOnError(bool cancelOnError = true)
引数と戻り値
cancelOnError = true
bool setterが例外を投げたときにTweenをキャンセルするか。
戻り値
MotionBuilder<TValue, TOptions, TAdapter>

Bind

補間値を書き込むsetterを登録して再生を開始します。状態付きの形式では、値に続いて登録時の状態が引数に渡されます。

public MotionHandle Bind(Action<TValue> action)
引数と戻り値
action
Action<TValue> 補間した値を受け取る処理。
戻り値
MotionHandle
public MotionHandle Bind<T1>(T1 state, Action<TValue, T1> action)
    where T1 : class
引数と戻り値
state
T1 setterの呼び出し時に補間値に続けて渡す状態。
action
Action<TValue, T1> 補間した値を受け取る処理。
戻り値
MotionHandle
public MotionHandle Bind<T1, T2>(T1 state0, T2 state1, Action<TValue, T1, T2> action)
    where T1 : class
    where T2 : class
引数と戻り値
state0
T1 setterの呼び出し時に補間値に続けて渡す状態。
state1
T2 setterの呼び出し時に補間値に続けて渡す状態。
action
Action<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
引数と戻り値
state0
T1 setterの呼び出し時に補間値に続けて渡す状態。
state1
T2 setterの呼び出し時に補間値に続けて渡す状態。
state2
T3 setterの呼び出し時に補間値に続けて渡す状態。
action
Action<TValue, T1, T2, T3> 補間した値を受け取る処理。
戻り値
MotionHandle

RunWithoutBinding

値を書き込むsetterを渡さずに再生し、時間制御や通知に使えるハンドルを返します。

public MotionHandle RunWithoutBinding()
戻り値
戻り値
MotionHandle

関連する型