protected override void OnStartRunning() { base.OnStartRunning(); archetype = EntityManager.CreateArchetype(typeof(UltraChunk)); float3 buildPos = math.floor(mainCamera.transform.position / (MeshComponents.radius / 4)); int offset = MeshComponents.radius / 4; NativeList <float3> positionList = new NativeList <float3>(Allocator.Temp); positionList.Add(GetPosition(new float3(buildPos.x - offset, 0, buildPos.z - offset) * (MeshComponents.radius / 4))); positionList.Add(GetPosition(new float3(buildPos.x + offset, 0, buildPos.z - offset) * (MeshComponents.radius / 4))); positionList.Add(GetPosition(new float3(buildPos.x - offset, 0, buildPos.z + offset) * (MeshComponents.radius / 4))); positionList.Add(GetPosition(new float3(buildPos.x + offset, 0, buildPos.z + offset) * (MeshComponents.radius / 4))); for (int i = 0; i < positionList.Length; i++) { BuildUltraChunks buildUltraChunkJobLeftDown = new BuildUltraChunks { archetype = archetype, commandBuffer = endSimulationEntityCommandBufferSystem.CreateCommandBuffer(), position = positionList[i] }; JobHandle job = buildUltraChunkJobLeftDown.Schedule(); endSimulationEntityCommandBufferSystem.AddJobHandleForProducer(job); } lastbuildPos = mainCamera.transform.position; }
protected override JobHandle OnUpdate(JobHandle inputDeps) { var Array = m_Query.ToComponentDataArray <BuildUltraChunkEvent>(Allocator.TempJob); var toBuild = Array[0]; Array.Dispose(); BuildUltraChunks buildUltraChunks = new BuildUltraChunks { archetype = archetype, commandBuffer = endSimulationEntityCommandBufferSystem.CreateCommandBuffer(), position = toBuild.positionToBuild, eventEntity = toBuild.eventEntity }; inputDeps = buildUltraChunks.Schedule(inputDeps); endSimulationEntityCommandBufferSystem.AddJobHandleForProducer(inputDeps); return(inputDeps); }