Last active
November 26, 2018 11:02
-
-
Save tsubaki/94044d82b714f56ab839b1961bd56536 to your computer and use it in GitHub Desktop.
ECSサンプル、並列化
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Unity.Entities; | |
using Unity.Jobs; | |
public class CountSystem : JobComponentSystem | |
{ | |
AddCounterJob job; | |
protected override void OnCreateManager(int capacity) | |
{ | |
base.OnCreateManager(capacity); | |
// ジョブを作っとく | |
job = new AddCounterJob(); | |
} | |
// ジョブを発行 | |
protected override JobHandle OnUpdate(JobHandle inputDeps) | |
{ | |
return job.Schedule(this, 64, inputDeps); | |
} | |
[Unity.Burst.BurstCompile] // Burstコンパイラに最適化属性 | |
struct AddCounterJob : IJobProcessComponentData<CountData> // 要求するComponentData | |
{ | |
public void Execute(ref CountData data) | |
{ | |
data.count++; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment