Firzus/agent-skills / skills/game/unity/unity-core
unity-core
VerifiedUse for any Unity task: writing, reviewing, or architecting Unity code, choosing between two Unity tools that do the same job, or when the user mentions Unity, CoreCLR, IL2CPP, Awaitable, Addressables, Content Directories, DOTS, ECS, Jobs, Burst, assembly definitions, Input System, audio, project structure, CI, builds, tests, or performance. Load it alongside the domain skills unity-ui, unity-editor-tools, unity-rendering, unity-multiplayer, unity-cli, and unity-play.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 8.6 KB |
| architecture.md | markdown | 8.8 KB |
| assets.md | markdown | 7.6 KB |
| code-standards.md | markdown | 2.1 KB |
| performance.md | markdown | 9.2 KB |
| project-structure.md | markdown | 5.7 KB |
| runtime.md | markdown | 6.8 KB |
| workflow.md | markdown | 9.6 KB |
code-standards.md
View on GitHub# Code standards — C# for Unity
Only what tooling does not already catch. If a rule can be written as an
`.editorconfig` line, it belongs in `.editorconfig`.
One thing to know about that filter: an `.editorconfig` naming rule only breaks
the build at severity `warning` or `error`. The default does not, which is why
teams believe a rule is enforced when it is not. Casing, layout, `var` usage and
file organisation all live there rather than here.
## Exceptions
- Throw the most specific exception that fits, and pass the parameter name when the type carries one.
- Catch only what the code can act on. A catch block that logs and continues turns a crash into corrupted state.
## Nullability
- Enable nullable reference types and treat the annotations as the contract. The analysis is compile-time only and does not trace into method bodies, so it narrows mistakes rather than eliminating them.
- Treat nullable annotations on serialized fields as advisory: the Unity runtime initialises them, which the compiler cannot see.
- `UnityEngine.Object` overloads `==` to report a destroyed object as null, which `?.`, `??`, `??=` and `is not null` all bypass. Microsoft.Unity.Analyzers catches all four with automatic fixes — see the analyzer row in [workflow.md](./workflow.md).
## Async
- Reserve `async void` for event handlers. Anywhere else its exceptions escape the caller entirely.
- In library code — an asmdef consumed by other projects — await with `ConfigureAwait(false)` unless the continuation needs the original context. Unity gameplay code wants the default, since it must resume on the main thread.
Engine async rules — `Awaitable`, `CancellationToken`, pooling — live in
[architecture.md](./architecture.md).
## Naming and layout
One public type per file, namespaces mirroring folders, asmdef naming: see
[project-structure.md](./project-structure.md).
## Sources
- <https://learn.microsoft.com/en-us/dotnet/standard/exceptions/best-practices-for-exceptions>
- <https://learn.microsoft.com/en-us/dotnet/csharp/nullable-references>
- <https://devblogs.microsoft.com/dotnet/configureawait-faq/>
- <https://github.com/microsoft/Microsoft.Unity.Analyzers>
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the work | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixes | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation code | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |