NativeAnimationCurve
Copy the keys and wrap modes of a Unity AnimationCurve into native storage for evaluation. Dispose after use.
public unsafe struct NativeAnimationCurve : IDisposableNativeAnimationCurve.cs · L8Sample 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.
var source = AnimationCurve.Linear(0f, 0f, 1f, 1f);
using var curve = new NativeAnimationCurve(source, Allocator.Temp);
float middle = curve.Evaluate(0.5f);
Members
IsCreated
Check whether native storage for the curve has been created.
public readonly bool IsCreated { get; }NativeAnimationCurve
Allocate curve storage. The overload taking an AnimationCurve also copies its keys and wrap modes.
public NativeAnimationCurve(AllocatorManager.AllocatorHandle allocator)Parameters
allocatorAllocatorManager.AllocatorHandleAllocator for native storage.
public NativeAnimationCurve(AnimationCurve animationCurve, AllocatorManager.AllocatorHandle allocator)Parameters
animationCurveAnimationCurveUnity AnimationCurve with its keys and pre/post wrap modes.allocatorAllocatorManager.AllocatorHandleAllocator for native storage.
CopyFrom
Replace the stored keys and wrap modes from the supplied AnimationCurve.
public void CopyFrom(AnimationCurve animationCurve)Parameters
animationCurveAnimationCurveUnity AnimationCurve with its keys and pre/post wrap modes.
public void CopyFrom(in NativeAnimationCurve animationCurve)Parameters
animationCurvein NativeAnimationCurveUnity AnimationCurve with its keys and pre/post wrap modes.
Evaluate
Evaluate the keys and wrap modes at the supplied time and return a float.
public float Evaluate(float time)Parameters and return value
timefloatTime at which to evaluate the curve.- Returns
float
Dispose
Release the native storage allocated for the curve.
public void Dispose()
MeatMotion