Exemple #1
0
    /// <summary> Fill </summary>
    public JobHandle Fill(STRUCT value, JobHandle dependency = default(JobHandle))
    {
        var job = new FillJob <STRUCT>(array: _array, value: value);

        return(Dependency = job.Schedule(
                   _array.Length, 1024,
                   JobHandle.CombineDependencies(dependency, Dependency)
                   ));
    }
Exemple #2
0
    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        var grid     = GetSingleton <PheromoneGrid>().Values;
        var settings = GetSingleton <AntManagerSettings>();

        int mapSize = settings.MapSize;

        var colors = new NativeArray <uint>(mapSize * mapSize, Allocator.TempJob);

        var job = new FillJob()
        {
            Colors = colors,
            Grid   = grid,
        };

        JobHandle jobHandle = job.Schedule(colors.Length, colors.Length / 8);

        jobHandle.Complete();

        Entities.WithoutBurst().WithAll <TagPheromoneRenderer>().ForEach((RenderMesh mesh) =>
        {
            var pheromoneTexture = mesh.material.mainTexture as Texture2D;

            if (pheromoneTexture == null)
            {
                pheromoneTexture          = new Texture2D(mapSize, mapSize);
                pheromoneTexture.wrapMode = TextureWrapMode.Mirror;

                mesh.material.mainTexture = pheromoneTexture;
            }

            pheromoneTexture.SetPixelData(colors, 0);
            pheromoneTexture.Apply();
        })
        .Run();

        colors.Dispose();

        return(inputDeps);
    }