protected override void OnUpdate() { NativeQueue <TileData> nativeQueue = new NativeQueue <TileData>(Allocator.TempJob); CopyTileJob copyTileJob = new CopyTileJob { nativeQueue = nativeQueue.ToConcurrent() }; JobHandle jobHandle = copyTileJob.Schedule(this); jobHandle.Complete(); NativeArray <TileData> nativeArray = new NativeArray <TileData>(nativeQueue.Count, Allocator.TempJob); NativeQueueToArrayJob nativeQueueToArrayJob = new NativeQueueToArrayJob { nativeQueue = nativeQueue, nativeArray = nativeArray, }; jobHandle = nativeQueueToArrayJob.Schedule(); jobHandle.Complete(); nativeQueue.Dispose(); var camera = Camera.main; //if (camera != null && Input.GetMouseButtonDown(0)) { var mousePosition = Input.mousePosition; var cameraRay = camera.ScreenPointToRay(mousePosition); Entities.WithAll <HexTileHightlightComponent>().ForEach((Entity entity) => { PostUpdateCommands.RemoveComponent <HexTileHightlightComponent>(entity); }); var deltaTime = Time.deltaTime; if (UnityEngine.Physics.Raycast(cameraRay, out var closestHit, float.PositiveInfinity)) { Vector3 mapPos = new Vector3(closestHit.point.x, 0, closestHit.point.z); CubeIndex index = HexUtils.FromPosition(mapPos, Bootstrap.Defines.TileRadius); Debug.DrawLine(Vector3.zero, closestHit.point, Color.red, 2.5f); for (int i = 0; i < nativeArray.Length; i++) { if (nativeArray[i].index.Equals(index)) { PostUpdateCommands.AddComponent(nativeArray[i].entity, new HexTileHightlightComponent()); break; } } } } nativeArray.Dispose(); }