Unity C# Naming Convention Reference
Click a category to see DevForge’s recommended naming conventions and examples.
Category
Variables & Fields
| Type | Convention | Example |
|---|---|---|
| Private field | camelCase, optional underscore prefix | _health or health |
| Public field / property | PascalCase | Health |
| Serialized private field | camelCase + [SerializeField] | [SerializeField] private float speed; |
| Constant | PascalCase or ALL_CAPS | MaxHealth or MAX_HEALTH |
| Static field | PascalCase | Instance |
| Boolean | is / has / can prefix | isGrounded, canJump |
| Local variable / parameter | camelCase, no prefix | float deltaTime |
Pick one private-field style (underscore prefix or not) and enforce it project-wide with an .editorconfig — consistency matters more than which style you pick.
Classes & Interfaces
| Type | Convention | Example |
|---|---|---|
| Class | PascalCase, noun | PlayerController |
| Interface | PascalCase, prefixed with I | IDamageable |
| MonoBehaviour | PascalCase, matches file name | EnemySpawner.cs |
| ScriptableObject | PascalCase + Data / Config / Settings suffix | WeaponData |
| Abstract class | PascalCase, often prefixed Base | BaseEnemy |
| Struct | PascalCase, noun | DamageInfo |
| Editor script | Target class + Editor suffix | EnemySpawnerEditor |
Unity requires the file name to match the MonoBehaviour class name exactly (case-sensitive) — mismatches are a common “script won’t attach” bug.
Methods
| Type | Convention | Example |
|---|---|---|
| Public method | PascalCase, verb-first | TakeDamage() |
| Private / helper method | PascalCase (C# convention) | CalculateArc() |
| Unity message method | Exact casing Unity expects | Awake(), OnTriggerEnter() |
| Coroutine | PascalCase, Routine / Coroutine suffix | FadeOutRoutine() |
| Event handler | Handle + event, or On + event | HandlePlayerDied() |
| Bool-returning method | Question-style verb | IsInRange(), TryGetTarget() |
| Async method | PascalCase + Async suffix | LoadLevelAsync() |
Unity’s own message methods (Update, OnCollisionEnter, etc.) must match Unity’s exact casing to be called by the engine — a typo there fails silently, no compile error.
Enums, Events & Namespaces
| Type | Convention | Example |
|---|---|---|
| Enum type | PascalCase, singular noun | WeaponType |
| Enum member | PascalCase, no prefix | WeaponType.Sword |
| Flags enum | Plural noun + [Flags] | DamageTypes.Fire | DamageTypes.Ice |
| C# event | PascalCase, past tense or On-prefixed | PlayerDied / OnPlayerDied |
| Delegate | PascalCase + Handler suffix | DamageHandler |
| UnityEvent field | Serialized, On-prefixed | onHealthChanged |
| Namespace | Company.Project.Feature | DevForge.Combat |
| Tag / Layer | PascalCase, matches a constant | "Enemy" → Tags.Enemy |
Wrap tag, layer, and animator-parameter strings in a static class of constants — a typo in CompareTag("Enemey") is another silent, runtime-only failure.
Folders
| Folder | Purpose |
|---|---|
Assets/_Project/ | Underscore prefix sorts your project folder above Unity’s default folders (Editor, Plugins, etc.) in the Project window. |
Scripts/ | Grouped by feature/system subfolder, not by type (avoid one giant flat Scripts folder). |
Art/Models/, Art/Textures/ | Split by asset type under a top-level Art folder. |
Prefabs/ | Mirror the Scripts feature folders where practical. |
ScriptableObjects/ | Keep data assets separate from prefabs/scripts. |
Scenes/ | Numbered for load order; keep test scenes in a Scenes/Sandbox/ subfolder. |
ThirdParty/ | Asset Store imports live here untouched — makes updates and license audits painless. |
Organize by feature (Player, Enemies, UI) at the top level, then by type inside each feature folder — easier to navigate than type-first for anything beyond a small prototype.
Assets (Prefabs, Materials, Textures)
| Asset type | Convention | Example |
|---|---|---|
| Prefab | PascalCase | PlayerCharacter.prefab |
| Material | PascalCase + _Mat suffix | Rock_Mat.mat |
| Texture | PascalCase + map-type suffix | Rock_Albedo.png, Rock_Normal.png |
| Animation clip | PascalCase, verb | PlayerJump.anim |
| Animator controller | PascalCase + _AC suffix | Player_AC.controller |
| Scene | PascalCase, numbered if ordered | 01_MainMenu.unity |
| Audio | Category prefix | SFX_Footstep_Grass.wav, MUS_MainTheme.ogg |
| Shader | PascalCase, path in name | DevForge/Toon/Lit |
Consistent texture suffixes (_Albedo, _Normal, _Metallic) make it obvious at a glance what a texture map is for, especially once a project has hundreds of them.
These match Microsoft’s C# conventions plus common Unity community practice. Whatever you choose, commit an .editorconfig to the repo so the IDE enforces it for everyone.
📚 Want to go beyond naming?
Consistent names are the first step toward maintainable code. Game Programming Patterns by Robert Nystrom is the natural next read, and it’s on our list of the best books for game developers.