Boat Attack使用了Universal RP的许多新图形功能,可以用于探索 Universal RP 的使用方式和技巧。
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

1.2 KiB

uid
ecs-jobs

Jobs in ECS

ECS uses the Job system to implement behavior -- the System part of ECS. An ECS System is concretely a Job created to transform the data stored in entity components

For example, the following system updates positions:

using Unity.Burst;
using Unity.Collections;
using Unity.Entities;
using Unity.Jobs;
using Unity.Transforms;
using UnityEngine;

public class MovementSpeedSystem : JobComponentSystem
{
    [BurstCompile]
    struct MovementSpeedJob : IJobForEach<Position, MovementSpeed>
    {
        public float dT;

        public void Execute(ref Position Position, [ReadOnly] ref MovementSpeed movementSpeed)
        {
            float3 moveSpeed = movementSpeed.Value * dT;
            Position.Value = Position.Value + moveSpeed;
        }
    }

    // OnUpdate runs on the main thread.
    protected override JobHandle OnUpdate(JobHandle inputDependencies)
    {
        var job = new MovementSpeedJob()
        {
            dT = Time.deltaTime
        };

        return job.Schedule(this, inputDependencies);
    }
}

For more information about systems, see ECS Systems.