Unity: Naming conventions

In this blog we will explain some naming conventions at the moment of write code in C# for Unity.

1. Introduction

If you started your coding in others languages like Python or Javascript, very propbably that you know a convention to write your code like camelCase, PascalCase, Snake_case or Kebab-case. This blog is focused in explain some of them and how they are used in Unity 2021. There is a last option, that is use your own convention, but if you are working in a team this will create problems of comunication.

in the next sections i will explain some naming conventions and some recommendations to use in Unity 2021

2. camelCase

The camelCase is one of the most used naming convention. In this case the first letter of the first word is in lower case and the first letter of every subsequent word is an uppercase, in the image above you can see an example.

In unity is recommended to use camelCase for properties and private variables.

3. PascalCase

In this case the first letter of every word is an upper case. This naming convenction is also one of the must used to code in Unity

It is used for naming new methods and for public elements in Unity.

4. snake_case

This a convention used mostly for Python, in this convention each space is replaced by an underscore. Is very rare to see someone using this naming convention for Unity.

5. Kebab-case

IIs not used very often. But is another convention that you can take into account. For this naming convention you have to replace all the spaces with a hyphen..

6. Recommendation for Unity

In the upper sections I showed you some naming conventions and how they are use in Unity, at this point, is your election which one you will use. Indepently which one you will use in your project, you have to be consistent from the beginnig util the end.

In the upper image you can find some final recommendations to implement at the moment to start your code in Unity.

If you find this blog useful let us a comment, and follow us in our Instagram @tortugamedev and Twitter @Totuas2.
And don’t forget to check out the rest of the blogs and our games!!

Leave a Comment

Your email address will not be published.