Exemplo n.º 1
0
    public static JobHandle Generate(NativeArray <Voxel> voxels, int3 chunkPosition, int chunkSize)
    {
        GenerateNoiseJob noiseJob = new GenerateNoiseJob {
            chunkPosition = chunkPosition, chunkSize = chunkSize, voxels = voxels
        };
        JobHandle noiseJobHandle = noiseJob.Schedule(voxels.Length, 32);

        JobHandle.ScheduleBatchedJobs();

        return(noiseJobHandle);
    }
Exemplo n.º 2
0
        public IEnumerator Generate(Voxel[] voxels, int3 chunkPosition, int3 chunkSize)
        {
            nativeVoxels.CopyFrom(voxels);

            GenerateNoiseJob noiseJob = new GenerateNoiseJob {
                chunkPosition = chunkPosition, chunkSize = chunkSize, voxels = nativeVoxels
            };

            jobHandle = noiseJob.Schedule(nativeVoxels.Length, 32);
            JobHandle.ScheduleBatchedJobs();
            int frameCount = 1;

            yield return(new WaitUntil(() =>
            {
                frameCount++;
                return jobHandle.IsCompleted || frameCount >= 4;
            }));

            jobHandle.Complete();

            nativeVoxels.CopyTo(voxels);
            nativeVoxels.Dispose();
        }