protected override JobHandle OnUpdate(JobHandle inputDeps) { NativeQueue <Entity> clickedButtons = new NativeQueue <Entity>(Allocator.TempJob); { ProcessClicks clicksJob = new ProcessClicks { EntityType = GetArchetypeChunkEntityType(), BufferType = GetArchetypeChunkBufferType <PointerInputBuffer>(), EventType = GetArchetypeChunkComponentType <PointerEvent>(), ButtonTargetType = GetComponentDataFromEntity <Button>(), ClickedButtons = clickedButtons.ToConcurrent() }; inputDeps = clicksJob.Schedule(m_EventGroup, inputDeps); inputDeps.Complete(); while (clickedButtons.TryDequeue(out Entity entity)) { EntityManager.AddComponent(entity, typeof(ButtonClickedEvent)); } } clickedButtons.Dispose(); return(inputDeps); }
protected override JobHandle OnUpdate(JobHandle inputDeps) { var commandBuff = m_Barrier.CreateAddFlagComponentCommandBuffer <ButtonClickedEvent>(); ProcessClicks clicksJob = new ProcessClicks { BufferType = GetArchetypeChunkBufferType <PointerInputBuffer>(), EventType = GetArchetypeChunkComponentType <PointerEvent>(), ButtonTargetType = GetComponentDataFromEntity <Button>(), ClickedButtons = commandBuff.AsParallelWriter() }; inputDeps = clicksJob.Schedule(m_EventGroup, inputDeps); m_Barrier.AddJobHandleForProducer(inputDeps); return(inputDeps); }