Skip to content

Instantly share code, notes, and snippets.

@HurricanKai
Created February 26, 2020 19:32
Show Gist options
  • Select an option

  • Save HurricanKai/af0f567bdc6a287891b3ea1d608d8a54 to your computer and use it in GitHub Desktop.

Select an option

Save HurricanKai/af0f567bdc6a287891b3ea1d608d8a54 to your computer and use it in GitHub Desktop.
DOTS getting started
using Unity.Entities;
using Unity.Mathematics;
[GenerateAuthoringComponent]
public struct Velocity : IComponentData
{
public float3 Value;
}
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