//struct UpdateColorFlagging : IJob //{ // public NativeHashMap<Entity, int> UpdateEntities; // public EntityCommandBuffer CommandBuffer; // public void Execute() // { // UpdateEntities.GetKeyArray(Allocator.Temp); // CommandBuffer.AddComponent() // } //} protected override JobHandle OnUpdate(JobHandle inputDeps) { if (m_EventGroup.CalculateLength() > 0) { m_TargetToEvent.Clear(); var selectableColorType = GetArchetypeChunkComponentType <SelectableColor>(true); var selectableType = GetArchetypeChunkComponentType <Selectable>(); var colorMultiplierType = GetArchetypeChunkComponentType <VertexColorMultiplier>(); var entityType = GetArchetypeChunkEntityType(); CreateTargetToEventMap createTargetToEvent = new CreateTargetToEventMap() { EntityType = GetArchetypeChunkEntityType(), EventType = GetArchetypeChunkComponentType <PointerEvent>(true), TargetToEvent = m_TargetToEvent.ToConcurrent() }; inputDeps = createTargetToEvent.Schedule(m_EventGroup, inputDeps); SetColorValueJob setJob = new SetColorValueJob() { SelectableColorType = selectableColorType, SelectableType = selectableType, ColorMultiplierType = colorMultiplierType, EntityType = entityType, PointerInputType = GetBufferFromEntity <PointerInputBuffer>(), TargetToEvent = m_TargetToEvent, }; inputDeps = setJob.Schedule(m_SelectableGroup, inputDeps); inputDeps.Complete(); EntityManager.AddComponent(m_TargetToEvent.GetKeyArray(Allocator.Temp), typeof(UpdateElementColor)); } return(inputDeps); }
protected override JobHandle OnUpdateInput(JobHandle inputDeps, NativeHashMap <Entity, Entity> targetToEvent, BufferFromEntity <PointerInputBuffer> pointerBufferFromEntity) { var selectableColorType = GetArchetypeChunkComponentType <SelectableColor>(true); var selectableType = GetArchetypeChunkComponentType <Selectable>(); var entityType = GetArchetypeChunkEntityType(); NativeHashMap <Entity, int> updateQueue = new NativeHashMap <Entity, int>(m_SelectableGroup.CalculateEntityCount(), Allocator.TempJob); SetColorValueJob setJob = new SetColorValueJob() { SelectableColorType = selectableColorType, SelectableType = selectableType, ColorMultiplierFromEntity = GetComponentDataFromEntity <VertexColorMultiplier>(), EntityType = entityType, PointerInputType = pointerBufferFromEntity, TargetToEvent = targetToEvent, ToUpdate = m_Barrier.CreateAddFlagComponentCommandBuffer <UpdateElementColor>().AsParallelWriter() }; inputDeps = setJob.Schedule(m_SelectableGroup, inputDeps); m_Barrier.AddJobHandleForProducer(inputDeps); inputDeps = updateQueue.Dispose(inputDeps); return(inputDeps); }