Skip to content

Instantly share code, notes, and snippets.

@tsubaki
Last active March 21, 2020 17:42
Show Gist options
  • Save tsubaki/3f9bb37216934d2fa0ddff32415b27ff to your computer and use it in GitHub Desktop.
Save tsubaki/3f9bb37216934d2fa0ddff32415b27ff to your computer and use it in GitHub Desktop.
新しいEntitiesを使用するためのコード
using Unity.Entities;
using Unity.Jobs;
using Unity.Mathematics;
using Unity.Transforms;
public class MySystem : SystemBase
{
protected override void OnUpdate()
{
var time = UnityEngine.Time.timeSinceLevelLoad;
this.Dependency = Entities.ForEach((ref Translation position) =>
{
position.Value += new float3(0, math.sin(time) ,0);
}).ScheduleParallel(this.Dependency);
}
}
@tsubaki
Copy link
Author

tsubaki commented Mar 17, 2020

ポイント

  • JobComponentSystemの代わりにSystemBaseを使用する
  • Entities.ForEachでフィールド変数を使うためには一旦ローカル変数にコピーする必要がある
  • inputDepsで取得していたようなジョブの依存関係はthis.Dependencyで取得する

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment