Skip to content

Code Convention

Merlijn edited this page Feb 10, 2026 · 2 revisions

Code Convention

Namespaces, types & classes are always UpperPascalCase.

namespace Pascal
{
   /// A Class in an namespace
   public class PascalCase
   {
      ////
   }
}

By public and private methodes & interfaces is it exactly the same and they are always verbs

private void PascalCase
{
   ////
}

public interface IChaseable
{
    void Magnitude(Vector3 velocity);
} 

Local variables (inclusive const) and parameters are lowerCamelCase's

private void StartGame(bool isReady)
{
   string signal = "START!"
   Const float timerInMinutes = 5
   
}

For naming:

  • private serializedfield it's lowerCamelCase
  • private fields _lowerCamelCase
  • public fields CamelCase

If the variable isn't called from another class or if you don't think you're gonna use it outside the class its automatically a private field. Only public are written as a PascalCase. The same rules implies if its static. For serializedfield you are using it only if you want to see it in the inspector or testing purposes. If it was for only testing purposes change the serializedfield into a normal private field. serializedfield is only needed for private fields.

[serializefield] private string camelCase;

private string _camelCase;

public static string PascalCase;

Conditions:

By If-statements: if the lines in the statements is not more than one don't use brackets

Example:

var result = True

/// one line
If(result)
   print("It works!")
else
   print("it didn't work")

if(result)
{
   print("It works!")
   result = False
}
else
{
  print("it didn't work")
  result = True
} 

The reason why because its unnecessary to use brackets by one lined code statements and this is more readable.

another expression is to use ternary ? and :

Example:

int x = 10;
int y = 20;

int result = x > y ? x : y;

what i am saying here is that if x is higher than y then is x the result, but if x is lesser than y, y is then the result.


Clone this wiki locally