Guest User

Untitled

a guest
Oct 19th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using Unity.Entities;
  5. using Unity.Jobs;
  6. using Unity.Collections;
  7. using Unity.Mathematics;
  8.  
  9. //[DisableAutoCreation]
  10. public class FilterShareredTest : JobComponentSystem
  11. {
  12. ComponentGroup group;
  13.  
  14. protected override void OnCreateManager()
  15. {
  16. group = GetComponentGroup(
  17. ComponentType.ReadOnly<AIData>(),
  18. ComponentType.Create<AnyData>());
  19. group.SetFilter(new AIData() { mode = 0 });
  20. }
  21.  
  22. protected override JobHandle OnUpdate(JobHandle handle)
  23. {
  24. var anyDataArray1 = group.GetComponentDataArray<AnyData>();
  25. return new ProcessJob() { anyDatas = anyDataArray1 }.Schedule(anyDataArray1.Length, 16, group.GetDependency());
  26. }
  27.  
  28. struct ProcessJob : IJobParallelFor
  29. {
  30. public ComponentDataArray<AnyData> anyDatas;
  31.  
  32. public void Execute(int index)
  33. {
  34. Debug.Log("job1");
  35. }
  36. }
  37.  
  38. struct ProcessJob2 : IJobParallelFor
  39. {
  40. public ComponentDataArray<AnyData> anyDatas;
  41.  
  42. public void Execute(int index)
  43. {
  44. Debug.Log("job2");
  45. }
  46. }
  47. }
Add Comment
Please, Sign In to add comment