Code Style - UltraStar-Deluxe/Play GitHub Wiki
-
Indent using 4 spaces
-
All curly braces get their own line
-
Use explicitly typed variables (no
varkeyword) -
Skip the constructor name when it is equal to the expected type name. For example, use
Bla bla = new(), don't useBla bla = new Bla(). -
PascalCase: NameSpace, Class, IInterface, EEnum, Method, Property, Constant, Event
-
camelCase: parameters, all fields
-
Prefixes: E for enums, I for interfaces, but none for private or static fields
-
Suffixes:
-
Scene: scenes files -
Ui: UXML files -
Manager: singleton classes -
Control: often used as suffix for a code counterpart of something. - Examples:
-
MainScene.unityhas a correspondingMainSceneUi.uxmlandMainSceneControl.cs. - There is a single
SettingsManagerinstance available in all scenes.
-
-
-
No acronyms, except for the above mentioned prefixes and common abbreviations, such as
HttporXml -
In code, acronyms should be treated as words, for example:
XmlHttpRequest -
Use
privatewhere possible -
Avoid
staticwhere possible- static fields have to be reset explicitly because Domain Reload is disabled for UltraStar Play.
Example:
public class MySceneControl
{
public int publicField;
int packagePrivate;
private int myPrivate;
protected int myProtected;
public string MyProperty { get; private set; }
public event Action<int> ValueChanged;
public MySceneControl()
{
List<string> stringList = new();
}
}
public enum EDay
{
Today, Tomorrow
}
public interface IXmlReader {
void ReadXml(string filePath);
}
The code style has been configured in a file .editorconfig,
which is supported by many IDEs (Visual Studio Code, Visual Studio, Rider, etc.).
Configure your IDE accordingly and follow above conventions.