MeatMotion

NativeAnimationCurve

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

Namespace
MeatMotion.Collections
Assembly
MeatMotion

メンバー一覧へ

public unsafe struct NativeAnimationCurve : IDisposable
NativeAnimationCurve.cs · L8

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

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

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

メンバー

IsCreated

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

public readonly bool IsCreated { get; }

NativeAnimationCurve

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

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

CopyFrom

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

public void CopyFrom(AnimationCurve animationCurve)
引数
animationCurve
AnimationCurve カーブのキーと前後のWrapModeを含むUnityのAnimationCurve。
public void CopyFrom(in NativeAnimationCurve animationCurve)
引数
animationCurve
in NativeAnimationCurve カーブのキーと前後のWrapModeを含むUnityのAnimationCurve。

Evaluate

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

public float Evaluate(float time)
引数と戻り値
time
float カーブを評価する時刻。
戻り値
float

Dispose

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