示例【Example】
以上图程序为例,这里使用两种方式实现
- 首先是 Normal Update 形式:
using System.Collections;
using System.Collections.Generic;
using Unity.Profiling;
using UnityEngine;
using UnityEngine.Jobs;
namespace Jobs.OOD
{
public class WaveCubes : MonoBehaviour
{
static readonly ProfilerMarker<int> profilerMarker = new ProfilerMarker<int>("WaveCubesWithJobs updateTransfrom", "Objects Count");
public GameObject cubeAchetype = null;
[Range(10, 100)] public int xHalfCount = 40;
[Range(10, 100)] public int zHalfCount = 40;
public List<Transform> cubeList;
// Start is called before the first frame update
void Start()
{
cubeList = new List<Transform>();
for (int z = -zHalfCount; z < zHalfCount; z++)
{
for (int x = -xHalfCount; x < xHalfCount; x++)
{
var cube = Instantiate(cubeAchetype);
cube.transform.position = new Vector3(x * 1.1f, 0, z * 1.1f);
cubeList.Add(cube.transform);
}
}
}
// Update is called once per frame
void Update()
{
using (profilerMarker.Auto(cubeList.Count))
{
for (var i = 0; i < cubeList.Count; i++)
{

最低0.47元/天 解锁文章
3645

被折叠的 条评论
为什么被折叠?



