Created
February 26, 2020 19:32
-
-
Save HurricanKai/af0f567bdc6a287891b3ea1d608d8a54 to your computer and use it in GitHub Desktop.
DOTS getting started
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using Unity.Entities; | |
| using Unity.Mathematics; | |
| [GenerateAuthoringComponent] | |
| public struct Velocity : IComponentData | |
| { | |
| public float3 Value; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using Unity.Burst; | |
| using Unity.Collections; | |
| using Unity.Entities; | |
| using Unity.Jobs; | |
| using Unity.Transforms; | |
| public class VelocitySystem : JobComponentSystem | |
| { | |
| [BurstCompile] | |
| private struct J : IJobForEach<Velocity, Translation> | |
| { | |
| public void Execute([ReadOnly] ref Velocity c0, ref Translation c1) | |
| { | |
| c1.Value += c0.Value; | |
| } | |
| } | |
| protected override JobHandle OnUpdate(JobHandle inputDeps) => new J().Schedule(this, inputDeps); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment