protected override JobHandle OnUpdate(JobHandle inputDeps) { inputDeps = new AnimationJob { dt = Time.deltaTime, }.Schedule(this, inputDeps); return(inputDeps); }
protected override JobHandle OnUpdate(JobHandle deps) { var job = new AnimationJob() { Time = UnityEngine.Time.time, DeltaTime = UnityEngine.Time.deltaTime }; return(job.Schedule(this, 32, deps)); }
protected override JobHandle OnUpdate(JobHandle deps) { for (var i = 0; i < _group.Length; i++) { var job = new AnimationJob() { Effector = _group.Effectors[i], Transform = _group.Transforms[i].worldToLocalMatrix, DeltaTime = UnityEngine.Time.deltaTime }; deps = job.Schedule(this, 32, deps); } return(deps); }
void Update() { t += speed * Time.deltaTime; var animJob = new AnimationJob() { Time = t, ShapeRadius = shapeRadius, ShapeSides = shapeSides, SideSize = sideSize, Radius = Radius, Rings = rings, CubesPerRing = cubesPerRing, //RingPositions = ringPositions, CubePositions = cubePositions, //RingRotations = ringRotations, CubeRotations = cubeRotations, CubeScales = cubeScales, MaterialParams = materialParams }; var animJobDep = animJob.Schedule(cubesPerRing * rings, 32); var transformJob = new TransformJob() { WorldMatrix = transform.localToWorldMatrix, //RingPositions = ringPositions, CubePositions = cubePositions, //RingRotations = ringRotations, CubeRotations = cubeRotations, CubeScales = cubeScales, RenderMatrices = renderMatrices, }; var transformJobDep = transformJob.Schedule(cubesPerRing * rings, 32, animJobDep); transformJobDep.Complete(); int objectCount = rings * cubesPerRing; int loopRenderBatchSize; MaterialPropertyBlock mpb = new MaterialPropertyBlock(); for (int i = 0; i < objectCount; i += renderBatchSize) { if ((i + renderBatchSize) < objectCount) { loopRenderBatchSize = renderBatchSize; } else { loopRenderBatchSize = objectCount - i; } if (renderBatchMat.Length != loopRenderBatchSize) { renderBatchMat = new Matrix4x4[loopRenderBatchSize]; instMatParamsArray = new float[loopRenderBatchSize]; } renderMatricesBatch = new NativeSlice <Matrix4x4>(renderMatrices, i, loopRenderBatchSize); renderMatricesBatch.CopyTo(renderBatchMat); materialParamsBatch = new NativeSlice <float>(materialParams, i, loopRenderBatchSize); materialParamsBatch.CopyTo(instMatParamsArray); mpb.SetFloatArray("FloatMPB", instMatParamsArray); Graphics.DrawMeshInstanced(mesh, 0, material, renderBatchMat, loopRenderBatchSize, mpb); } }