I have basic ECS job system up and running which is great, but they all run without any “run” or “execute” command from main script. The JobComponentSystem runs without any scripting. It has OnUpdate method that schedules the its own job but there is nothing I can do to control it.
If I want the game to stop or pause executing this JobComponentSystem, how do I go on about doing that?
public class TreeMoveSystem : JobComponentSystem
{
[BurstCompile]
private struct UpdateTreeMoveJob : IJobForEach<Translation, MoveSpeedComponent>
{
public float deltaTime;
public void Execute(ref Translation translation, ref MoveSpeedComponent moveSpeedComponent)
{
translation.Value.y += moveSpeedComponent.moveSpeed * deltaTime;
if (translation.Value.y > 10f)
{
moveSpeedComponent.moveSpeed = -math.abs(moveSpeedComponent.moveSpeed);
}
if (translation.Value.y < -10f)
{
moveSpeedComponent.moveSpeed = math.abs(moveSpeedComponent.moveSpeed);
}
}
}
protected override JobHandle OnUpdate(JobHandle inputDeps)
{
UpdateTreeMoveJob updateTreeMoveJob = new UpdateTreeMoveJob
{
deltaTime = Time.deltaTime
};
JobHandle jobHandle = updateTreeMoveJob.Schedule(this);
return jobHandle;
}
}
So basically if I have this script in the project, it just runs… no matter what.