Unity naming convention reference banner

Unity C# Naming Convention Reference

Click a category to see DevForge’s recommended naming conventions and examples.

Category

Variables & Fields

TypeConventionExample
Private fieldcamelCase, optional underscore prefix_health or health
Public field / propertyPascalCaseHealth
Serialized private fieldcamelCase + [SerializeField][SerializeField] private float speed;
ConstantPascalCase or ALL_CAPSMaxHealth or MAX_HEALTH
Static fieldPascalCaseInstance
Booleanis / has / can prefixisGrounded, canJump
Local variable / parametercamelCase, no prefixfloat 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

TypeConventionExample
ClassPascalCase, nounPlayerController
InterfacePascalCase, prefixed with IIDamageable
MonoBehaviourPascalCase, matches file nameEnemySpawner.cs
ScriptableObjectPascalCase + Data / Config / Settings suffixWeaponData
Abstract classPascalCase, often prefixed BaseBaseEnemy
StructPascalCase, nounDamageInfo
Editor scriptTarget class + Editor suffixEnemySpawnerEditor

Unity requires the file name to match the MonoBehaviour class name exactly (case-sensitive) — mismatches are a common “script won’t attach” bug.

Methods

TypeConventionExample
Public methodPascalCase, verb-firstTakeDamage()
Private / helper methodPascalCase (C# convention)CalculateArc()
Unity message methodExact casing Unity expectsAwake(), OnTriggerEnter()
CoroutinePascalCase, Routine / Coroutine suffixFadeOutRoutine()
Event handlerHandle + event, or On + eventHandlePlayerDied()
Bool-returning methodQuestion-style verbIsInRange(), TryGetTarget()
Async methodPascalCase + Async suffixLoadLevelAsync()

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

TypeConventionExample
Enum typePascalCase, singular nounWeaponType
Enum memberPascalCase, no prefixWeaponType.Sword
Flags enumPlural noun + [Flags]DamageTypes.Fire | DamageTypes.Ice
C# eventPascalCase, past tense or On-prefixedPlayerDied / OnPlayerDied
DelegatePascalCase + Handler suffixDamageHandler
UnityEvent fieldSerialized, On-prefixedonHealthChanged
NamespaceCompany.Project.FeatureDevForge.Combat
Tag / LayerPascalCase, 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

FolderPurpose
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 typeConventionExample
PrefabPascalCasePlayerCharacter.prefab
MaterialPascalCase + _Mat suffixRock_Mat.mat
TexturePascalCase + map-type suffixRock_Albedo.png, Rock_Normal.png
Animation clipPascalCase, verbPlayerJump.anim
Animator controllerPascalCase + _AC suffixPlayer_AC.controller
ScenePascalCase, numbered if ordered01_MainMenu.unity
AudioCategory prefixSFX_Footstep_Grass.wav, MUS_MainTheme.ogg
ShaderPascalCase, path in nameDevForge/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.

See our recommended books →