-
Notifications
You must be signed in to change notification settings - Fork 0
Code Conventions
MitchelMA edited this page Mar 6, 2025
·
8 revisions
- Local variables must be a specific defined data type. The use of "var" is strictly prohibited
Don't do:
private void Funtion() { var myInt= 1; }
Do:
private void Funtion() { int myInt= 1; }
- Class name = PascalCase
Class name in pascal-case
public class MyClass
{
}- Property name = Pascalcase
Property name in pascal-case
public int MyInt => 1;- Serialisefield = Pascalcase
Serialisefield name in pascal-case
[SerialialiseField]
private int MyInt;
public int OtherInt;- non serialisefield = camelCase
non serialisefield name in camel-case
[HideInInspector]
public int myInt;- private function names must have an underscore in front of it
private name with underscore
private int _myInt;- Function names = PascalCase
Function name with pascal-case
private void MyFunction()
{
}scoped parameters = camelCase
Scoped parameter with camel-case
{
int myInt = 1;
}- function parameters = camelCase
function parameter with camel-case
private void MyFunction(int myInt)
{
}- Serialised fields
- Events
- Properties
- Non serialised fields
- Private variables
- functions
- Example:
[SerialisedField]
private int SerialisedFieldInt;
public UnityEvent onUnityEvent;
public int PropertyInt=> 1;
[HideInInspector]
public int nonSerialisedFieldInt;
private int _myPrivateInt
private void MyFunction()
{
}