2025 updated edition of the C# code style guide is now available

Hi everyone,

We’re happy to announce that we just launched the second edition of our C# code style guide for Unity. The e-book is packed with advice from industry experts on how to use or adapt existing industry standard code style guides. Establishing such a guide for everyone in your team to follow will help ensure your codebase can grow your project to a commercial-scale production.

These tips and tricks will help your development process in the long term, even if they cost you extra effort up front. A cleaner, more scalable codebase also facilitates the efficient onboarding of new developers as you expand your team.

Download the new C# code style guide here.


Using the example of simple Pong-style game to illustrate the single-responsibility principle; in this case, refactoring a Paddle class into single responsibilities

This new edition tackles the #1 objection from the first edition up front

Many of the readers of the first edition asked us why we don’t just recommend that Unity devs follow the existing industry standards. Well, our code style guide actually extends Microsoft’s Framework Design Guidelines.

However, we don’t enforce the same code style across all of our beginner tutorials, documentation, and sample projects. The main reason for doing this is that a strict style guide can get in the way of the learning curve for beginner users vs a need to enforce more strict guidelines when working in large teams and more advanced use cases. There are simply different needs for someone just learning Unity and perhaps their first programming language, and engineering teams with 2000+ people.

Depending on the type of project you are working on, how many teammates are contributing to the code base, etc., you might feel a different need as well.

But one common point most game developers would agree on is that you need clean code: Code that is easy to read and efficient to maintain and reuse.

What’s in the latest edition of the code style guide?


The updated C# code style guide

This guide takes the guesswork out of coding conventions and formatting. Consistent style then becomes a matter of following directions.

Chances are you already have preferences for how to write your code today. However, your teammates of tomorrow will most likely have different preferences. While there is no right solution this guide provides some tips on how you can leverage a style guide to agree on standards.

In the guide we tackle topics that aim to make development more scalable and conform to a set of production standards, including:

  • Follow consistent naming conventions
  • Format your code for legibility
  • Organize classes and methods to keep them small and readable
  • Comment on any code that isn’t self-explanatory

Based on your feedback we made a few minor changes to our recommendations. Again, it doesn’t vary a lot from the general C# recommendations or our recommendation to prioritize readability over efficiency, etc. We also added a few more examples so it’s easier to translate the theory into daily work. If there are any topics you are particularly interested in, let us know and we can look into creating a dedicated article or video tutorial on it.

We also added a new section on UI Toolkit: With UI Toolkit becoming more popular, a lot of you have asked about some general recommendations for naming conventions. We generally recommend the Block Element Modifier (BEM) naming convention for your visual elements in the UXML and Style Sheets classes. BEM is widely used in the context of CSS and modern web development that is the inspiration for UI Toolkit. In the e-book we added a chapter that dives into the why and how as well as providing some examples you can use for inspiration.

Download the new C# code style guide here.

If you are interested in more resources that can guide you in writing clean, scalable code, then make sure to check out our new articles series on SOLID with Peter from Sunny Valley, plus our recently updated programming design patterns project and e-book.

Level_up_1200x628

5 Likes