// Update is called once per frame void Update() { handle.Complete(); for (int i = 0; i < targets.Length; i++) { var targetPosition = targets[i].position; var direction = Vector3.down; var command = new RaycastCommand(targetPosition, direction); commands[i] = command; } // 移動的command 設定 UpdatePosition updatePositionJob = new UpdatePosition() { raycastResults = results, objVelocitys = velocities }; ApplyPosition applyPosition = new ApplyPosition() { objVelocitys = velocities }; var raycastJobHandle = RaycastCommand.ScheduleBatch(commands, results, 20); var updatePositionHandle = updatePositionJob.Schedule(transformArray.length, 20, raycastJobHandle); handle = applyPosition.Schedule(transformArray, updatePositionHandle); }
void Update() { handle.Complete(); // Raycastの開始点と位置を設定 for (int i = 0; i < transformArray.length; i++) { var targetPosition = transformArray[i].position; var direction = Vector3.down; var command = new RaycastCommand(targetPosition, direction); commands[i] = command; } // 移動のコマンドを設定 UpdatePosition updatePositionJob = new UpdatePosition() { raycastResults = results, velocitys = velocity }; ApplyPosition applyPosition = new ApplyPosition() { velocitys = velocity }; // 並列処理を実行(即完了待ち) // 終わったらコマンドに使ったバッファは不要なので破棄 var raycastJobHandle = RaycastCommand.ScheduleBatch(commands, results, 20); var updatePositionHandle = updatePositionJob.Schedule(transformArray.length, 20, raycastJobHandle); handle = applyPosition.Schedule(transformArray, updatePositionHandle); JobHandle.ScheduleBatchedJobs(); }
void LateUpdate() { handle.Complete(); // Raycastの開始点と位置を設定 for (int i = 0; i < transformArray.length; i++) { var targetPosition = transformArray[i].position; var direction = Vector3.down; var command = new RaycastCommand(targetPosition, direction); commands[i] = command; } // 移動のコマンドを設定 var updatePositionJob = new UpdateVelocity() { velocitys = velocity }; var applyPosition = new ApplyPosition() { velocitys = velocity }; // 並列処理を実行(即完了待ち) // 終わったらコマンドに使ったバッファは不要なので破棄 handle = RaycastCommand.ScheduleBatch(commands, results, 20); handle = hitCheckJob.Schedule(transformArray.length, 20, handle); handle = new ReflectionJob { velocitys = velocity, result = hitQueue }.Schedule(handle); handle = updatePositionJob.Schedule(transformArray.length, 20, handle); handle = applyPosition.Schedule(transformArray, handle); handle.Complete(); }
void Update() { handle.Complete(); hitcheckHandle.Complete(); this.transform.Rotate(0, 10f, 0); for (int i = 0; i < transformArray.length; i++) { var targetPosition = transformArray[i].position; var direction = Vector3.down; var command = new RaycastCommand(targetPosition, direction); commands[i] = command; gs[i].transform.Rotate(0, 10f, 0); } var updatePositionJob = new UpdatePosition() { raycastResults = results, velocitys = velocity }; var applyPosition = new ApplyPosition() { velocitys = velocity }; var raycastJobHandle = RaycastCommand.ScheduleBatch(commands, results, 20); hitcheckHandle = hitCheckJob.Schedule(raycastJobHandle); var updatePositionHandle = updatePositionJob.Schedule(transformArray.length, 20, raycastJobHandle); handle = applyPosition.Schedule(transformArray, updatePositionHandle); JobHandle.ScheduleBatchedJobs(); }