# NativeAnimationCurve

Copy the keys and wrap modes of a Unity AnimationCurve into native storage for evaluation. Dispose after use.

Namespace: MeatMotion.Collections

Assembly: MeatMotion

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

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

## Sample a copy of an AnimationCurve

Add `using MeatMotion.Collections;`, `using Unity.Collections;` and `using UnityEngine;`. The linear curve evaluates to 0.5 at its midpoint.

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

## IsCreated

Check whether native storage for the curve has been created.

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

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

## NativeAnimationCurve

Allocate curve storage. The overload taking an AnimationCurve also copies its keys and wrap modes.

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

Parameters

- `allocator` (`AllocatorManager.AllocatorHandle`) Allocator for native storage.

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

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

Parameters

- `animationCurve` (`AnimationCurve`) Unity AnimationCurve with its keys and pre/post wrap modes.
- `allocator` (`AllocatorManager.AllocatorHandle`) Allocator for native storage.

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

## CopyFrom

Replace the stored keys and wrap modes from the supplied AnimationCurve.

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

Parameters

- `animationCurve` (`AnimationCurve`) Unity AnimationCurve with its keys and pre/post wrap modes.

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

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

Parameters

- `animationCurve` (`in NativeAnimationCurve`) Unity AnimationCurve with its keys and pre/post wrap modes.

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

## Evaluate

Evaluate the keys and wrap modes at the supplied time and return a float.

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

Parameters and return value

- `time` (`float`) Time at which to evaluate the curve.
- Returns: `float`

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

## Dispose

Release the native storage allocated for the curve.

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

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