× Phaseshift FCOM Tutorials

Organise your C# scripts


These C# attributes and directives can help you better organise your code

Adding these Attributes to your code can improve readability and minimise mistakes. It can also help other developers dive into your code and better understand what's going on and how they can add to your code in a meaningful way.

Deprecating/Obsolete


You can tag properties, methods and classes as deprecated or obsolete. This flag gets shown whenever Visual Studio or Intellisense would recommend or auto-correct a method when you are typing to let you know not to use, or to use an alternative method instead.

You can also add a second bool parameter to determine whether to completely stop usage of the method. False allows usage, true will return an error when called.

Tooltips


Tooltips can be added to methods, variables and other properties to show handy little tooltips in the Unity Editor. This especially useful to show the user what a property in an object does without having to open up Visual Studio.

#Region


#region can be used to 'block-off' a piece of code so that it can be minimised in Visual Studio to better section off your code. It is best to use #region sparingly however, and is best practice to not nest regions inside of other regions. The next developer to work on your code with thank you! Code readability is very important!

Range


The Range feature is useful when you want to limit the minimum and maximum acceptable values of a certain variable in the Unity Editor.

Documentation


To explore more on these topics, check out the documentation:

Obsolete
Tooltip
Region
Range

Liked this article?

Please consider sharing!
Author

Josh Lyell

Game Developer