# NativeAnimationCurve

UnityのAnimationCurveからキーとWrapModeをコピーし、ネイティブ領域で評価します。利用後はDisposeします。

Namespace: MeatMotion.Collections

Assembly: MeatMotion

```csharp
public unsafe struct NativeAnimationCurve : IDisposable
```

[Runtime/Collections/NativeAnimationCurve.cs · L8](../../source/Runtime/Collections/NativeAnimationCurve.cs.html#L8)

## Unityのカーブをコピーして評価する

`using MeatMotion.Collections;`、`using Unity.Collections;`、`using UnityEngine;` を追加します。線形カーブの中点は0.5です。

```csharp
var source = AnimationCurve.Linear(0f, 0f, 1f, 1f);
using var curve = new NativeAnimationCurve(source, Allocator.Temp);
float middle = curve.Evaluate(0.5f);
```

## IsCreated

カーブのネイティブ領域が割り当てられているかを返します。

```csharp
public readonly bool IsCreated { get; }
```

[Runtime/Collections/NativeAnimationCurve.cs · L12](../../source/Runtime/Collections/NativeAnimationCurve.cs.html#L12)

## NativeAnimationCurve

指定したAllocatorでカーブを作ります。AnimationCurveを渡す形式では、そのキーとWrapModeをコピーします。

```csharp
public NativeAnimationCurve(AllocatorManager.AllocatorHandle allocator)
```

引数

- `allocator` (`AllocatorManager.AllocatorHandle`) ネイティブ領域に使用するアロケーター。

[Runtime/Collections/NativeAnimationCurve.cs · L14](../../source/Runtime/Collections/NativeAnimationCurve.cs.html#L14)

```csharp
public NativeAnimationCurve(AnimationCurve animationCurve, AllocatorManager.AllocatorHandle allocator)
```

引数

- `animationCurve` (`AnimationCurve`) カーブのキーと前後のWrapModeを含むUnityのAnimationCurve。
- `allocator` (`AllocatorManager.AllocatorHandle`) ネイティブ領域に使用するアロケーター。

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

## CopyFrom

既存のカーブデータを渡したAnimationCurveのキーとWrapModeで更新します。

```csharp
public void CopyFrom(AnimationCurve animationCurve)
```

引数

- `animationCurve` (`AnimationCurve`) カーブのキーと前後のWrapModeを含むUnityのAnimationCurve。

[Runtime/Collections/NativeAnimationCurve.cs · L28](../../source/Runtime/Collections/NativeAnimationCurve.cs.html#L28)

```csharp
public void CopyFrom(in NativeAnimationCurve animationCurve)
```

引数

- `animationCurve` (`in NativeAnimationCurve`) カーブのキーと前後のWrapModeを含むUnityのAnimationCurve。

[Runtime/Collections/NativeAnimationCurve.cs · L38](../../source/Runtime/Collections/NativeAnimationCurve.cs.html#L38)

## Evaluate

指定した時刻でキーとWrapModeを評価してfloatを返します。

```csharp
public float Evaluate(float time)
```

引数と戻り値

- `time` (`float`) カーブを評価する時刻。
- 戻り値: `float`

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

## Dispose

カーブ用に確保したネイティブ領域を解放します。

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

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