Home › Unity (C#) › Unity C# game dev rules
Unity C# game dev rules
Cursor rules for Unity 6 projects in C#: performance, MonoBehaviour lifecycle, ScriptableObjects.
CursorUnity (C#)
How to use
Save this as .cursor/rules/unity.mdc in your repository root, commit it, and your agent will pick it up automatically. Edit the commands to match your project.
.cursor/rules/unity.mdcDownload ---
description: Unity C# conventions
globs: ["Assets/**/*.cs"]
---
# Unity (C#)
- Unity 6 LTS, C# 9. Namespaces mirror folders under `Assets/_Project/Scripts`.
- Serialize private fields with `[SerializeField] private`; don't make fields public just for the Inspector.
- Cache component references in `Awake`; never call `GetComponent`, `Find`, or `Camera.main` inside `Update`.
- No allocations in hot paths: avoid LINQ, string concatenation, and `new` in `Update`/`FixedUpdate`. Use object pools for spawned objects.
- Physics in `FixedUpdate`, input and visuals in `Update`. Use the new Input System.
- Config and shared data in ScriptableObjects; events via C# events or ScriptableObject event channels instead of singletons.
- Use `async`/Awaitable or coroutines for timed sequences; always cancel on `OnDisable`.
- Never edit `.meta` files or scene YAML by hand.
- Mark editor-only code with `#if UNITY_EDITOR` or put it in an `Editor/` folder.