Massive Performance Gains
DOTS leverages the Burst compiler and Entity Component System (ECS) to achieve near-native performance. Traditional Unity games might handle thousands of entities, but DOTS enables millions.
Key Benefits:
- ✓ 10-100x more entities than GameObject/MonoBehaviour
- ✓ Optimal cache utilization through data locality
- ✓ Automatic multithreading with Job System
Entity Component System
DOTS replaces GameObjects with a pure ECS architecture where:
Entities
Lightweight IDs representing game objects
Components
Pure data without behavior
Systems
Process components in efficient batches
This separation enables optimal CPU cache usage and makes your game logic inherently parallelizable.
Burst Compiler
The Burst compiler transforms C# jobs into highly optimized native code using LLVM, achieving performance comparable to hand-written C++.
Compilation Pipeline:
C# Job Code
Write safe, managed code
Burst Compilation
LLVM optimizations applied
Native Execution
Near-C++ performance
[ReadOnly] public NativeArray<float> input;
[WriteOnly] public NativeArray<float> output;
public void Execute(int i) {
output[i] = input[i] * 2f;
}
}
DOTS Use Cases
Mass Simulation Games
RTS units, crowds, particles, or physics objects that need to scale to thousands or millions of entities.
Procedural Generation
Generate massive worlds or content quickly using parallelized algorithms.
High-Performance VR/AR
Maintain high framerates with complex scenes in demanding XR environments.
Getting Started with DOTS
1. Install DOTS Packages
Unity > Window > Package Manager
Install:
- Entities
- Burst
- Mathematics
- Collections
2. Convert GameObjects (Optional)
Use the ConvertToEntity MonoBehaviour to gradually migrate existing GameObjects to ECS.
public class ConvertMe : MonoBehaviour, IConvertGameObjectToEntity {
public void Convert(Entity entity, EntityManager dstManager,
GameObjectConversionSystem conversionSystem) {
// Add ECS components here
}
}
3. Write Your First System
[BurstCompile]
public struct RotationSpeed : IComponentData {
public float RadiansPerSecond;
}
[BurstCompile]
public class RotationSystem : SystemBase {
protected override void OnUpdate() {
float deltaTime = Time.DeltaTime;
Entities.ForEach((ref Rotation rotation,
in RotationSpeed speed) => {
rotation.Value = math.mul(
math.normalize(rotation.Value),
quaternion.AxisAngle(
math.up(),
speed.RadiansPerSecond * deltaTime));
}).ScheduleParallel();
}
}