MotionUpdateJob<TValue, TOptions, TAdapter>
NativeArray内のTweenを並列評価し、値と回収対象のインデックスを別々に出力します。完了リストの容量は呼び出し側で確保します。
public struct MotionUpdateJob<TValue, TOptions, TAdapter> : IJobParallelFor
where TValue : unmanaged
where TOptions : unmanaged, IMotionOptions
where TAdapter : unmanaged, IMotionAdapter<TValue, TOptions>MotionUpdateJob.cs · L91件のfloatをJobで評価する
using MeatMotion;、using MeatMotion.Adapters;、using Unity.Collections;、using Unity.Jobs; を追加します。1件分の出力と完了リストを確保し、Jobの完了を待ってから結果4を読み取ります。
using var motions = new NativeArray<MotionUpdateJob<float, NoOptions, FloatMotionAdapter>.Motion>(
1, Allocator.TempJob);
using var output = new NativeArray<float>(1, Allocator.TempJob);
using var retired = new NativeList<int>(1, Allocator.TempJob);
var entries = motions;
entries[0] = new MotionUpdateJob<float, NoOptions, FloatMotionAdapter>.Motion(0f, 8f, 1f);
var job = new MotionUpdateJob<float, NoOptions, FloatMotionAdapter>
{
Motions = motions, Output = output, CompletedIndexList = retired.AsParallelWriter(),
DeltaTime = 0.5, UnscaledDeltaTime = 0.5, RealDeltaTime = 0.5
};
job.Schedule(1, 1).Complete();
float value = output[0];
メンバー
Motions
評価対象のMotionを格納したNativeArrayです。
public NativeArray<Motion> Motions;DeltaTime
TimeKind.Timeの要素に適用するスケール時間の差分秒数です。
public double DeltaTime;UnscaledDeltaTime
TimeKind.UnscaledTimeの要素に適用する非スケールの差分秒数です。
public double UnscaledDeltaTime;RealDeltaTime
TimeKind.Realtimeの要素に適用する実時間の差分秒数です。
public double RealDeltaTime;Output
評価した値を入力のMotionと同じインデックスに書き込みます。
public NativeArray<TValue> Output;CompletedIndexList
回収する要素の番号を書き込みます。実行前に対象件数分の空き容量を確保してください。
public NativeList<int>.ParallelWriter CompletedIndexList;Execute
指定要素を時計に合わせて1回評価し、状態と値を更新します。
MeatMotion