Home › Unity (C#) › Unity DOTS / ECS rules

Unity DOTS / ECS rules

Cursor rules for Unity Entities 1.x (DOTS): baking, ISystem with Burst, jobs, IJobEntity, and structural changes.

CursorUnity (C#)

How to use

Save this as .cursor/rules/unity-dots.mdc in your repository root, commit it, and your agent will pick it up automatically. Edit the commands to match your project.

Note: Review and test before use. Provided as is, without warranty. See Terms.

.cursor/rules/unity-dots.mdcDownload  
---
description: Unity DOTS / ECS conventions
globs: ["Assets/**/*.cs"]
alwaysApply: false
---

# Unity DOTS (Entities 1.x)

- Authoring MonoBehaviours + `Baker<T>` convert GameObjects in SubScenes to entities. Runtime code never touches GameObjects for ECS data.
- Components are small unmanaged `struct`s implementing `IComponentData` (or `IBufferElementData`, `IEnableableComponent`). No managed types in hot-path components.
- Systems are `partial struct` implementing `ISystem` with `[BurstCompile]` on `OnCreate`/`OnUpdate`. Use `SystemBase` only when managed code is unavoidable.
- Declare requirements in `OnCreate` (`state.RequireForUpdate<GameConfig>()`) and read singletons via `SystemAPI.GetSingleton<T>()`.
- Iterate with `foreach (var (transform, speed) in SystemAPI.Query<RefRW<LocalTransform>, RefRO<Speed>>())` for simple cases; schedule `IJobEntity` (`new MoveJob { Dt = SystemAPI.Time.DeltaTime }.ScheduleParallel()`) for heavy work.
- Use `RefRO` when you only read, so the job scheduler can parallelize.
- Structural changes (create/destroy/add/remove components) go through an `EntityCommandBuffer` from `BeginSimulationEntityCommandBufferSystem.Singleton`, using `.AsParallelWriter()` in parallel jobs.
- Prefer enableable components over adding/removing tags every frame.
- Order systems with `[UpdateInGroup]`, `[UpdateBefore/After]`.
- Native containers allocated with the right `Allocator` and disposed (or `Allocator.Temp` inside a frame).

## Done when
No Burst compile errors or safety-system exceptions in Play mode, and the Entities Profiler shows the new systems within budget.

More: all Unity (C#) rules · all Cursor rules

Related rules

Unity C# game dev rules

Cursor rules for Unity 6 projects in C#: performance, MonoBehaviour lifecycle, ScriptableObjects.

CursorUnity (C#)

Unity 6 C# Windsurf rules

Windsurf rules for Unity 6 projects in C#: MonoBehaviour lifecycle, ScriptableObjects, Input System, and performance.

WindsurfUnity (C#)

Godot 4 C# rules

Cursor rules for Godot 4.x games written in C# (.NET 8): node scripts, signals, exports, and performance.

CursorGodot

LÖVE (Love2D) Lua game rules

Cursor rules for 2D games with LÖVE 11.5 in Lua: callbacks, modules, delta time, asset loading, and performance.

CursorLÖVE (Love2D)

Roblox Luau rules

Cursor rules for Roblox experiences in Luau: strict typing, client/server boundaries, remotes, and data saving.

CursorRoblox (Luau)

Three.js rules

Cursor rules for Three.js (r17x, ES modules) web 3D and games: render loop, disposal, assets, and performance.

CursorThree.js

Get new rules weekly

One email a week: fresh rule files, agent tips, and what's changing in Cursor, Claude Code and Copilot. Free, unsubscribe anytime.

Opens the Rulestack Newsletter on beehiiv in a new tab. Or subscribe directly on beehiiv.