Code lines are not allowed to exceed 120 characters so that code will always be readable on most screen sizes.
Every file and folder name is written in UpperCamelCase.
Brackets are placed on a new line and not on the same line.
public class ExampleScript
{
}
The namespace name is written in UpperCamelCase and is based on the folder name the script is placed in. Every class needs to be inside of a namespace.
namespace ExampleNamespace
{
public class ExampleScript : MonoBehaviour
{
}
}
The Class name is written in UpperCamelCase and always has a summary. If the function GetComponent
is used to get a component from this GameObject you use RequireComponent
above the class.
/// <summary>
/// A summary explaining what the class is for.
/// </summary>
[RequireComponent(typeof(ExampleComponent))]
public class ExampleScript : MonoBehaviour
{
private void Awake()
{
ExampleComponent exampleComponent = GetComponent<ExampleComponent>();
}
}