Пример #1
0
        /// <summary>
        /// Schedule parallel jobs to rebuild the internal mesh data. Requires read-only access to the
        /// tiles array.
        /// </summary>
        /// <returns>The job handle for the scheduled jobs.</returns>
        public JobHandle ScheduleUploadTileData(NativeArray <Tile> tiles, JobHandle inputDeps = default)
        {
            _isDirty = true;

            _rebuildDataJob = JobHandle.CombineDependencies(inputDeps, _rebuildDataJob);

            float2 uvSize = new float2(1f / 16f);

            var uvsJob = new UVJob
            {
                tiles  = tiles,
                uvs    = _tileUVs,
                uvSize = uvSize,
            }.Schedule(tiles.Length, 64, _rebuildDataJob);

            var colorJob = new ColorsJob
            {
                tiles    = tiles,
                fgColors = _fgColors,
                bgColors = _bgColors,
            }.Schedule(tiles.Length, 64, _rebuildDataJob);

            _rebuildDataJob = JobHandle.CombineDependencies(uvsJob, colorJob);

            return(_rebuildDataJob);
        }
Пример #2
0
        /// <summary>
        /// Immediately rebuilds internal rendering data using the given tiles.
        /// </summary>
        public void UploadTileData(NativeArray <Tile> tiles)
        {
            // Force mesh refresh on next Update
            _isDirty = true;

            _rebuildDataJob.Complete();

            float2 uvSize = new float2(1f / 16f);

            var uvsJob = new UVJob
            {
                tiles  = tiles,
                uvs    = _tileUVs,
                uvSize = uvSize,
            }.Schedule(tiles.Length, 64, _rebuildDataJob);

            var colorJob = new ColorsJob
            {
                tiles    = tiles,
                fgColors = _fgColors,
                bgColors = _bgColors,
            }.Schedule(tiles.Length, 64, _rebuildDataJob);

            var jobs = JobHandle.CombineDependencies(uvsJob, colorJob);

            jobs.Complete();
        }