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.

Related rules

Astro content site rules

Cursor rules for Astro 5 sites with content collections, islands, and zero-JS-by-default pages.

CursorAstro

Chrome extension (Manifest V3) rules

Cursor rules for building Manifest V3 browser extensions with TypeScript and minimal permissions.

CursorChrome extensions

Cloudflare Agents SDK rules

Cursor rules for stateful AI agents on Cloudflare (agents package): Durable Object state, SQL, scheduling, and WebSockets.

CursorCloudflare Workers / Hono

Convex backend rules

Cursor rules for Convex backends: schema, validated queries/mutations/actions, indexes, and auth checks.

CursorConvex

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.