Skip to content

A inspirational C# code style guide for Unity projects

Notifications You must be signed in to change notification settings

thomasjacobsen-unity/Unity-Code-Style-Guide

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

An example of a Unity C# code style guide

Why should you consider a code style guide?

A code style guide provides a clear set of rules or guidelines that each developer on a team should adhere to when writing code. While there is no one correct way to format your Unity C# code, agreeing on a consistent style across the team can help you develop a clean, readable, and scalable codebase. A code style guide helps you remove the guesswork for every member of your team by establishing consensus around important coding conventions, thereby supporting the growth of your codebase into a commercial-scale production. We created this example code style guide as a source of inspiration for Unity developers.

How to use the guide

Find inspiration in existing guides as a starting point to creating your own. Our guide focuses on the most common coding conventions you’ll encounter during Unity development. These are essentially all a subset of the Microsoft Framework Design guidelines, which include an extensive number of rules beyond what is presented here. The guidelines we provide are recommendations, not hard and fast rules. Review each rule in the example style guide and customize it to your team’s preferences. The specifics of an individual rule are less important than having everyone agree to follow it consistently. When in doubt, rely on your team’s own guide to settle any style disagreements. Your style guide should take precedence over our suggestions or the Microsoft Framework Design guidelines, if they are in conflict. This will allow your team to maintain a uniform style throughout your project.

Who created this guide and how can I use it?

We created the guide based on best practices shared by internal and external Unity experts. A big thanks goes to Unity Game Academy for their significant contribution in bringing the guide together. As a lead on the project behind our accompanying e-book, Creating a C# style guide for clean and scalable game code, I chose to make the guide available here on my Unity GitHub account. This guide is a product of our own subjective opinions, and as such, it is legally meant to serve as an example for inspiration only.

You can also find two webbased articles here:
Naming and code style tips
Formatting best practices

Remember, a good style guide is one that fits your needs and covers the majority of the day-to-day use cases in your game development. Our intention is for you to use the style guide as a starting point, or as bits and pieces in your own guide. Download our ebook

Interested in learning more?

If you’d like further inspiration for creating your own code style guide, check out our upcoming blog post and our new e-book, Create a C# style guide: Write cleaner code that scales.

About

A inspirational C# code style guide for Unity projects

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages