# MotionBuilder<TValue, TOptions, TAdapter>

Configure easing, loops, callbacks and scheduling for a value, options type and adapter. Bind schedules the configured motion.

Namespace: MeatMotion

Assembly: MeatMotion

```csharp
public struct MotionBuilder<TValue, TOptions, TAdapter> : IDisposable
    where TValue : unmanaged
    where TOptions : unmanaged, IMotionOptions
    where TAdapter : unmanaged, IMotionAdapter<TValue, TOptions>
```

[Runtime/Builders/MotionBuilder.cs · L11](../../../source/Runtime/Builders/MotionBuilder.cs.html#L11)

## Reuse the same settings

Add `using MeatMotion;`. Capture settings before binding to create multiple independently controlled motions.

```csharp
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

Capture the configuration before binding and pass it to MMotion.Create to reuse it.

```csharp
public MotionSettings<TValue, TOptions> ToMotionSettings()
```

Return value

- Returns: `MotionSettings<TValue, TOptions>`

[Runtime/Builders/MotionBuilder.cs · L40](../../../source/Runtime/Builders/MotionBuilder.cs.html#L40)

## Dispose

Return the shared builder buffer. Struct copies are invalidated too. Obtain a new builder before configuring or binding again.

```csharp
public void Dispose()
```

[Runtime/Builders/MotionBuilder.cs · L84](../../../source/Runtime/Builders/MotionBuilder.cs.html#L84)

## WithScheduler

Choose the automatic update phase or manual world before binding.

```csharp
public MotionBuilder<TValue, TOptions, TAdapter> WithScheduler(MotionWorld world)
```

Parameters and return value

- `world` (`MotionWorld`) MotionWorld in which to schedule the tween.
- Returns: `MotionBuilder<TValue, TOptions, TAdapter>`

[Runtime/Builders/MotionBuilder.cs · L118](../../../source/Runtime/Builders/MotionBuilder.cs.html#L118)

```csharp
public MotionBuilder<TValue, TOptions, TAdapter> WithScheduler(IMotionScheduler scheduler)
```

Parameters and return value

- `scheduler` (`IMotionScheduler`) Scheduler that determines where the motion is registered and updated.
- Returns: `MotionBuilder<TValue, TOptions, TAdapter>`

[Runtime/Builders/MotionBuilder.cs · L124](../../../source/Runtime/Builders/MotionBuilder.cs.html#L124)

## WithEase

Choose the curve that maps normalized time to progress. When used with Bind, an AnimationCurve is sampled from a snapshot taken at bind time.

```csharp
public MotionBuilder<TValue, TOptions, TAdapter> WithEase(Easing easing)
```

Parameters and return value

- `easing` (`Easing`) Easing function mapping normalized time to progress.
- Returns: `MotionBuilder<TValue, TOptions, TAdapter>`

[Runtime/Builders/MotionBuilder.cs · L130](../../../source/Runtime/Builders/MotionBuilder.cs.html#L130)

```csharp
public MotionBuilder<TValue, TOptions, TAdapter> WithEase(Ease ease)
```

Parameters and return value

- `ease` (`Ease`) Easing function mapping normalized time to progress.
- Returns: `MotionBuilder<TValue, TOptions, TAdapter>`

[Runtime/Builders/MotionBuilder.cs · L136](../../../source/Runtime/Builders/MotionBuilder.cs.html#L136)

```csharp
public MotionBuilder<TValue, TOptions, TAdapter> WithEase(AnimationCurve animationCurve)
```

Parameters and return value

- `animationCurve` (`AnimationCurve`) Unity AnimationCurve with its keys and pre/post wrap modes.
- Returns: `MotionBuilder<TValue, TOptions, TAdapter>`

[Runtime/Builders/MotionBuilder.cs · L142](../../../source/Runtime/Builders/MotionBuilder.cs.html#L142)

## WithLoops

Set the loop count and LoopType. Stop an infinite loop by canceling it.

```csharp
public MotionBuilder<TValue, TOptions, TAdapter> WithLoops(int loops, LoopType loopType = LoopType.Restart)
```

Parameters and return value

- `loops` (`int`) Loop count. Use -1 for an infinite loop.
- `loopType = LoopType.Restart` (`LoopType`) How progress is evaluated on successive passes.
- Returns: `MotionBuilder<TValue, TOptions, TAdapter>`

[Runtime/Builders/MotionBuilder.cs · L148](../../../source/Runtime/Builders/MotionBuilder.cs.html#L148)

## WithDelay

Set a delay in seconds and choose which loops receive it. skipValuesDuringDelay controls writes while waiting.

```csharp
public MotionBuilder<TValue, TOptions, TAdapter> WithDelay(float delay, DelayType delayType = DelayType.FirstLoop, bool skipValuesDuringDelay = true)
```

Parameters and return value

- `delay` (`float`) Delay before interpolation, in seconds.
- `delayType = DelayType.FirstLoop` (`DelayType`) Apply the delay once or before every loop.
- `skipValuesDuringDelay = true` (`bool`) Whether to skip setter writes during a delay.
- Returns: `MotionBuilder<TValue, TOptions, TAdapter>`

[Runtime/Builders/MotionBuilder.cs · L154](../../../source/Runtime/Builders/MotionBuilder.cs.html#L154)

## WithImmediateBind

Pass false to suppress the initial write at bind time, for example on a later sequence child targeting the same property.

```csharp
public MotionBuilder<TValue, TOptions, TAdapter> WithImmediateBind(bool immediateBind = true)
```

Parameters and return value

- `immediateBind = true` (`bool`) Whether to write the start value immediately upon binding.
- Returns: `MotionBuilder<TValue, TOptions, TAdapter>`

[Runtime/Builders/MotionBuilder.cs · L160](../../../source/Runtime/Builders/MotionBuilder.cs.html#L160)

## WithOnCancel

Register work to run when the motion is canceled.

```csharp
public MotionBuilder<TValue, TOptions, TAdapter> WithOnCancel(Action callback)
```

Parameters and return value

- `callback` (`Action`) Register work to run when the motion is canceled.
- Returns: `MotionBuilder<TValue, TOptions, TAdapter>`

[Runtime/Builders/MotionBuilder.cs · L166](../../../source/Runtime/Builders/MotionBuilder.cs.html#L166)

## WithDebugName

Set a name for identifying the tween in the Editor or a Development Build.

```csharp
public MotionBuilder<TValue, TOptions, TAdapter> WithDebugName(string debugName)
```

Parameters and return value

- `debugName` (`string`) Name used to identify the tween while debugging.
- Returns: `MotionBuilder<TValue, TOptions, TAdapter>`

[Runtime/Builders/MotionBuilder.cs · L172](../../../source/Runtime/Builders/MotionBuilder.cs.html#L172)

## WithOnComplete

Register work to run on completion, including explicit completion.

```csharp
public MotionBuilder<TValue, TOptions, TAdapter> WithOnComplete(Action callback)
```

Parameters and return value

- `callback` (`Action`) Register work to run on completion, including explicit completion.
- Returns: `MotionBuilder<TValue, TOptions, TAdapter>`

[Runtime/Builders/MotionBuilder.cs · L178](../../../source/Runtime/Builders/MotionBuilder.cs.html#L178)

## WithOnLoopComplete

Register a callback that receives the completed loop count at a loop boundary.

```csharp
public MotionBuilder<TValue, TOptions, TAdapter> WithOnLoopComplete(Action<int> callback)
```

Parameters and return value

- `callback` (`Action<int>`) Register a callback that receives the completed loop count at a loop boundary.
- Returns: `MotionBuilder<TValue, TOptions, TAdapter>`

[Runtime/Builders/MotionBuilder.cs · L184](../../../source/Runtime/Builders/MotionBuilder.cs.html#L184)

## WithOptions

Assign the options struct passed to the value adapter.

```csharp
public MotionBuilder<TValue, TOptions, TAdapter> WithOptions(TOptions options)
```

Parameters and return value

- `options` (`TOptions`) Options passed to this value adapter.
- Returns: `MotionBuilder<TValue, TOptions, TAdapter>`

[Runtime/Builders/MotionBuilder.cs · L190](../../../source/Runtime/Builders/MotionBuilder.cs.html#L190)

## WithCancelOnError

Choose whether an exception from the bound setter cancels this tween.

```csharp
public MotionBuilder<TValue, TOptions, TAdapter> WithCancelOnError(bool cancelOnError = true)
```

Parameters and return value

- `cancelOnError = true` (`bool`) Whether an exception from the setter cancels the motion.
- Returns: `MotionBuilder<TValue, TOptions, TAdapter>`

[Runtime/Builders/MotionBuilder.cs · L196](../../../source/Runtime/Builders/MotionBuilder.cs.html#L196)

## Bind

Schedule the tween with a value setter. Stateful overloads pass the bound state after the interpolated value.

```csharp
public MotionHandle Bind(Action<TValue> action)
```

Parameters and return value

- `action` (`Action<TValue>`) Callback receiving the sampled value.
- Returns: `MotionHandle`

[Runtime/Builders/MotionBuilder.cs · L202](../../../source/Runtime/Builders/MotionBuilder.cs.html#L202)

```csharp
public MotionHandle Bind<T1>(T1 state, Action<TValue, T1> action)
    where T1 : class
```

Parameters and return value

- `state` (`T1`) State passed to the setter after the interpolated value.
- `action` (`Action<TValue, T1>`) Callback receiving the sampled value.
- Returns: `MotionHandle`

[Runtime/Builders/MotionBuilder.cs · L210](../../../source/Runtime/Builders/MotionBuilder.cs.html#L210)

```csharp
public MotionHandle Bind<T1, T2>(T1 state0, T2 state1, Action<TValue, T1, T2> action)
    where T1 : class
    where T2 : class
```

Parameters and return value

- `state0` (`T1`) State passed to the setter after the interpolated value.
- `state1` (`T2`) State passed to the setter after the interpolated value.
- `action` (`Action<TValue, T1, T2>`) Callback receiving the sampled value.
- Returns: `MotionHandle`

[Runtime/Builders/MotionBuilder.cs · L225](../../../source/Runtime/Builders/MotionBuilder.cs.html#L225)

```csharp
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
```

Parameters and return value

- `state0` (`T1`) State passed to the setter after the interpolated value.
- `state1` (`T2`) State passed to the setter after the interpolated value.
- `state2` (`T3`) State passed to the setter after the interpolated value.
- `action` (`Action<TValue, T1, T2, T3>`) Callback receiving the sampled value.
- Returns: `MotionHandle`

[Runtime/Builders/MotionBuilder.cs · L233](../../../source/Runtime/Builders/MotionBuilder.cs.html#L233)

## RunWithoutBinding

Schedule without a value setter and return a handle for timing and callbacks.

```csharp
public MotionHandle RunWithoutBinding()
```

Return value

- Returns: `MotionHandle`

[Runtime/Builders/MotionBuilder.cs · L242](../../../source/Runtime/Builders/MotionBuilder.cs.html#L242)

## Related types

- [MMotion](../../../en/api/mmotion/index.md)

- [MotionBuilderExtensions](../../../en/api/motionbuilderextensions/index.md)

- [MotionHandle](../../../en/api/motionhandle/index.md)

- [AudioMotionExtensions](../../../en/api/extensions-audiomotionextensions/index.md)

- [CameraMotionExtensions](../../../en/api/extensions-cameramotionextensions/index.md)

- [LoggerMotionExtensions](../../../en/api/extensions-loggermotionextensions/index.md)

- [MaterialMotionExtensions](../../../en/api/extensions-materialmotionextensions/index.md)

- [ProgressMotionExtensions](../../../en/api/extensions-progressmotionextensions/index.md)

- [RectTransformMotionExtensions](../../../en/api/extensions-recttransformmotionextensions/index.md)

- [Rigidbody2DMotionExtensions](../../../en/api/extensions-rigidbody2dmotionextensions/index.md)

- [RigidbodyMotionExtensions](../../../en/api/extensions-rigidbodymotionextensions/index.md)

- [SpriteRendererMotionExtensions](../../../en/api/extensions-spriterenderermotionextensions/index.md)

- [TextMeshProMotionExtensions](../../../en/api/extensions-textmeshpromotionextensions/index.md)

- [TransformMotionExtensions](../../../en/api/extensions-transformmotionextensions/index.md)

- [UGUIMotionExtensions](../../../en/api/extensions-uguimotionextensions/index.md)

- [UIToolkitMotionExtensions](../../../en/api/extensions-uitoolkitmotionextensions/index.md)

- [VisualEffectMotionExtensions](../../../en/api/extensions-visualeffectmotionextensions/index.md)

- [VolumeMotionExtensions](../../../en/api/extensions-volumemotionextensions/index.md)

- [R3MotionExtensions](../../../en/api/r3motionextensions/index.md)

- [UniRxMotionExtensions](../../../en/api/unirxmotionextensions/index.md)

- [UniTaskMotionExtensions](../../../en/api/unitaskmotionextensions/index.md)
