protected override JobHandle OnUpdate(JobHandle inputDeps) { var rotateJob = new RotateJob(); rotateJob.dt = Time.deltaTime; return(rotateJob.Schedule(this, inputDeps)); }
protected override JobHandle OnUpdate(JobHandle inputDeps) { RotateJob job = new RotateJob(Time.DeltaTime); JobHandle handler = job.Schedule(this, inputDeps); return(handler); }
protected override void OnUpdate() { var job = new RotateJob(); job.time = (float)Time.ElapsedTime; job.Schedule(this).Complete(); }
protected override JobHandle OnUpdate(JobHandle inputDeps) { var rotate = new RotateJob { deltaTime = Time.DeltaTime }; return(rotate.Schedule(this, inputDeps)); }
protected override JobHandle OnUpdate(JobHandle inputDeps) { var job = new RotateJob { deltaTime = Time.deltaTime }; return(job.Schedule(this, 64, inputDeps)); }
protected override JobHandle OnUpdate(JobHandle inputDeps) { RotateJob rotateJob = new RotateJob() { deltaTime = Time.deltaTime }; JobHandle rotateHandle = rotateJob.Schedule(this, 4, inputDeps); return(rotateHandle); }
private void Update() { // 잡 생성 RotateJob rJob = new RotateJob { t = Time.time, speed = 2f, radius = 0.05f }; // 잡 예약(실행) JobHandle handle = rJob.Schedule(_transformAccessArray); }
protected override JobHandle OnUpdate(JobHandle inputDeps) { var job = new RotateJob { rotations = _rotationGroup.rotations, rotationSpeeds = _rotationGroup.rotationSpeeds, controlData = _rotationGroup.controlData, dt = Time.deltaTime }; return(job.Schedule(_rotationGroup.Length, 1, inputDeps)); }
void Update() { // 1.准备数据 for (int i = 0; i < gameCount; i++) { tmpVelocitys[i] = new Vector3(0, 1, 0); //tmpPositions[i] = tmpPositions[i] + tmpVelocitys[i] * Time.deltaTime; tmpPositions[i] = gameObjs[i].transform.position; tmpQuaternion[i] = gameObjs[i].transform.rotation; } VelocityJob job = new VelocityJob() { positions = tmpPositions, delaTime = Time.deltaTime, velocitys = tmpVelocitys }; RotateJob rotateJob = new RotateJob() { deltaTime = Time.deltaTime, quaternions = tmpQuaternion }; //依赖按照速度计算的到的位置数组 ApplyTransform applyTransform = new ApplyTransform() { positions = tmpPositions, quaternions = tmpQuaternion }; // 2.执行 //信号量 主线程如何知道子线程执行完毕 gameCount 指定总共子线程执行数据数量 10:每个子线程以下处理多少次 JobHandle jobHandle = job.Schedule(gameCount, 10); // 移动 Job JobHandle rotateHandle = rotateJob.Schedule(gameCount, 10); // 旋转 Job JobHandle combineHandle = JobHandle.CombineDependencies(jobHandle, rotateHandle); // 赋值job 共同依赖联合的句柄~~ JobHandle tranHandle = applyTransform.Schedule(tranAccessArray, combineHandle); // 对 obj 赋值 job // 3.同步 jobHandle.Complete(); rotateHandle.Complete(); tranHandle.Complete(); //4。更新位置 //for (int i = 0; i < gameCount; i++) //{ // gameObjs[i].transform.position = tmpPositions[i]; //} }
protected override JobHandle OnUpdate(JobHandle inputDeps) { var rotationType = GetArchetypeChunkComponentType <Rotation>(); var rotateType = GetArchetypeChunkComponentType <IJobChunk_RotateData>(true); RotateJob rotateJob = new RotateJob { deltaTime = Time.deltaTime, rotationType = rotationType, rotateDataType = rotateType, }; JobHandle jobHandle = rotateJob.Schedule(m_group, inputDeps); return(jobHandle); }
protected override JobHandle OnUpdate(JobHandle inputDeps) { updateAccu += Time.deltaTime; float2 inputAxis = new float2(0, 0); if (Input.GetKey(KeyCode.A)) { inputAxis.x -= 1; } if (Input.GetKey(KeyCode.D)) { inputAxis.x += 1; } if (Input.GetKey(KeyCode.S)) { inputAxis.y -= 1; } if (Input.GetKey(KeyCode.W)) { inputAxis.y += 1; } var rotationJob = new RotateJob() { inputAxis = inputAxis, }; var rotationJobHandle = rotationJob.Schedule(this, inputDeps); var movementJob = new MovementJob() { snakeBodyBuffer = GetBufferFromEntity <SnakeBodyBuffer>(), dt = Time.deltaTime, accu = updateAccu, updateTimer = updateTimer }; var movementJobHandle = movementJob.Schedule(this, rotationJobHandle); EntityCommandBuffer cmd = new EntityCommandBuffer(Allocator.TempJob); var concurrentCmd = cmd.ToConcurrent(); var updateBodyJob = new UpdateBodyJob() { cmd = concurrentCmd, snakeBodyBuffer = GetBufferFromEntity <SnakeBodyBuffer>(true), dt = Time.deltaTime, }; var updateJobHandle = updateBodyJob.Schedule(this, movementJobHandle); updateJobHandle.Complete(); cmd.Playback(World.Active.EntityManager); cmd.Dispose(); if (updateAccu >= updateTimer) { updateAccu = 0; } return(updateJobHandle); }