# MotionHandle

登録済みTweenの時刻、速度、寿命を操作します。シーケンスに追加した子をシークするときは親のハンドルを使います。

Namespace: MeatMotion

Assembly: MeatMotion

```csharp
public struct MotionHandle : IEquatable<MotionHandle>
```

[Runtime/MotionHandle.cs · L5](../../source/Runtime/MotionHandle.cs.html#L5)

## シークして現在位置で止める

`using MeatMotion;` を追加します。1秒のTweenを0.75秒にシークすると値は6になります。Cancel後はworldを進めても値は6のままです。

```csharp
float value = 0f;
using var world = new MotionWorld();
var handle = MMotion.Create(0f, 8f, 1f)
    .WithScheduler(world)
    .Bind(v => value = v);
handle.Time = 0.75;
handle.Cancel();
world.Tick(0.1);
```

## StorageId

ハンドルが属するストレージの識別子です。

```csharp
public int StorageId;
```

[Runtime/MotionHandle.cs · L7](../../source/Runtime/MotionHandle.cs.html#L7)

## Index

ストレージ内のスロット番号です。識別にはStorageIdとVersionも使用します。

```csharp
public int Index;
```

[Runtime/MotionHandle.cs · L7](../../source/Runtime/MotionHandle.cs.html#L7)

## Version

同じスロットが別のTweenに再利用されたときに識別する世代番号です。

```csharp
public int Version;
```

[Runtime/MotionHandle.cs · L7](../../source/Runtime/MotionHandle.cs.html#L7)

## None

どのTweenも参照しない既定のハンドルです。

```csharp
public static readonly MotionHandle None;
```

[Runtime/MotionHandle.cs · L16](../../source/Runtime/MotionHandle.cs.html#L16)

## ToString

値の文字列表現を返します。

```csharp
public override readonly string ToString()
```

戻り値

- 戻り値: `string`

[Runtime/MotionHandle.cs · L17](../../source/Runtime/MotionHandle.cs.html#L17)

## Equals

同じ値を表すか比較します。

```csharp
public readonly bool Equals(MotionHandle other)
```

引数と戻り値

- `other` (`MotionHandle`) 等値比較の対象。
- 戻り値: `bool`

[Runtime/MotionHandle.cs · L18](../../source/Runtime/MotionHandle.cs.html#L18)

```csharp
public override readonly bool Equals(object obj)
```

引数と戻り値

- `obj` (`object`) 等値比較の対象。
- 戻り値: `bool`

[Runtime/MotionHandle.cs · L19](../../source/Runtime/MotionHandle.cs.html#L19)

## GetHashCode

等値比較に対応するハッシュコードを返します。

```csharp
public override readonly int GetHashCode()
```

戻り値

- 戻り値: `int`

[Runtime/MotionHandle.cs · L20](../../source/Runtime/MotionHandle.cs.html#L20)

## operator ==

同じハンドルか比較します。

```csharp
public static bool operator ==(MotionHandle a, MotionHandle b)
```

引数と戻り値

- `a` (`MotionHandle`) 等値比較の対象。
- `b` (`MotionHandle`) 等値比較の対象。
- 戻り値: `bool`

[Runtime/MotionHandle.cs · L21](../../source/Runtime/MotionHandle.cs.html#L21)

## operator !=

異なるハンドルか比較します。

```csharp
public static bool operator !=(MotionHandle a, MotionHandle b)
```

引数と戻り値

- `a` (`MotionHandle`) 等値比較の対象。
- `b` (`MotionHandle`) 等値比較の対象。
- 戻り値: `bool`

[Runtime/MotionHandle.cs · L22](../../source/Runtime/MotionHandle.cs.html#L22)

## IsActive

ハンドルに対応するTweenが有効か返します。保持したTweenは終端に到達した後も有効な場合があります。

```csharp
public readonly bool IsActive()
```

戻り値

- 戻り値: `bool`

[Runtime/MotionHandle.cs · L23](../../source/Runtime/MotionHandle.cs.html#L23)

## IsPlaying

有効で終端に達していないTweenならtrueを返します。PlaybackSpeedが0でもこの条件で判定します。

```csharp
public readonly bool IsPlaying()
```

戻り値

- 戻り値: `bool`

[Runtime/MotionHandle.cs · L24](../../source/Runtime/MotionHandle.cs.html#L24)

## TotalDuration

遅延・ループを含めた全体の再生秒数です。無限ループでは正の無限大になります。

```csharp
public readonly double TotalDuration { get; }
```

[Runtime/MotionHandle.cs · L39](../../source/Runtime/MotionHandle.cs.html#L39)

## Duration

構成した補間区間の長さを秒で取得します。

```csharp
public readonly float Duration { get; }
```

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

## Delay

ビルダーで設定した遅延秒数を返します。

```csharp
public readonly float Delay { get; }
```

[Runtime/MotionHandle.cs · L44](../../source/Runtime/MotionHandle.cs.html#L44)

## Loops

設定されているループ数を返します。

```csharp
public readonly int Loops { get; }
```

[Runtime/MotionHandle.cs · L45](../../source/Runtime/MotionHandle.cs.html#L45)

## CompletedLoops

既に通過したループ数をルートハンドルから読み取ります。

```csharp
public readonly int CompletedLoops { get; }
```

[Runtime/MotionHandle.cs · L46](../../source/Runtime/MotionHandle.cs.html#L46)

## PlaybackSpeed

1は通常速度、0は停止、負の値は逆方向です。NaNや無限大の設定は例外になります。

```csharp
public float PlaybackSpeed { get; set; }
```

[Runtime/MotionHandle.cs · L47](../../source/Runtime/MotionHandle.cs.html#L47)

## Preserve

完了後もハンドルから再シークできるようにルートTweenを保持します。

```csharp
public MotionHandle Preserve()
```

戻り値

- 戻り値: `MotionHandle`

[Runtime/MotionHandle.cs · L59](../../source/Runtime/MotionHandle.cs.html#L59)

## Time

経過秒数を読み取ります。有限の時刻を書き込むとルートTweenをシークし、対応する位置の値を反映します。

```csharp
public double Time { get; set; }
```

[Runtime/MotionHandle.cs · L66](../../source/Runtime/MotionHandle.cs.html#L66)

## Complete

有限のルートTweenを終端まで進めて完了させます。無限ループやシーケンスが所有する子には使用できません。

```csharp
public void Complete()
```

[Runtime/MotionHandle.cs · L77](../../source/Runtime/MotionHandle.cs.html#L77)

## Cancel

現在の値でルートTweenを停止し、キャンセル通知を発行します。

```csharp
public void Cancel()
```

[Runtime/MotionHandle.cs · L85](../../source/Runtime/MotionHandle.cs.html#L85)

## TryComplete

再生中の有限のルートなら完了してtrueを返します。

```csharp
public bool TryComplete()
```

戻り値

- 戻り値: `bool`

[Runtime/MotionHandle.cs · L86](../../source/Runtime/MotionHandle.cs.html#L86)

## TryCancel

キャンセル可能なルートなら停止してtrueを返します。無効なハンドルや親が所有する子ではfalseになります。

```csharp
public bool TryCancel()
```

戻り値

- 戻り値: `bool`

[Runtime/MotionHandle.cs · L92](../../source/Runtime/MotionHandle.cs.html#L92)

## 関連する型

- [CompositeMotionHandle](../../api/compositemotionhandle/index.md)

- [MotionHandleExtensions](../../api/motionhandleextensions/index.md)

- [MotionSequenceBuilder](../../api/motionsequencebuilder/index.md)

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

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