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

Universal vibe-coding guardrails

Always-on Cursor rules that keep any AI agent careful: plan first, small diffs, verify, never fake it.

CursorAny stack

Next.js App Router (TypeScript) rules

Cursor project rules for Next.js 15 App Router apps with TypeScript, Server Components, and Tailwind.

CursorNext.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.