Game Development Reference
In-Depth Information
Properties and Unity
Properties are useful to validate and control the assignment of values
to variables. The main problem with using them in Unity concerns their
visibility in the Object Inspector. Specifically, C# properties are not
shown in the Object Inspector. You can neither get nor set their values
in the editor. However, community-made scripts and solutions are
available that can change this default behavior, for example exposing
C# properties. These scripts and solutions can be found at http://
wiki.unity3d.com/index.php?title=Expose_properties_
in_inspector .
More information on Properties in C# can be found at http://msdn.microsoft.
com/en-GB/library/x9fsa0sw.aspx .
Commenting
Commenting is the practice of inserting human readable messages into your code,
purely for annotation, description, and to make things clearer to the reader. In C#,
one-line comments are prefixed with the // symbol, and multiline comments begin
with /* and end with */ . Comments are used throughout the code samples in this
topic. Comments are important, and I recommend that you get into the habit of
using them if you're not already in the habit. They benefit not only other developers
in your team (if you work with others), but you too! They help remind you of what
your code is doing when you return to it weeks or months later, and they even
help you get clear and straight about the code you're writing right now. Of course,
all these benefits depend on you writing concise and meaningful comments and
not long essays filled with irrelevance. However, MonoDevelop offers XML-based
comments too to describe functions and arguments specifically and which integrates
with code completion. It can significantly boost your workflow, especially when
working in teams. Let's see how to use this. Start by writing your function or any
function, as shown in the following screenshot:
Writing a function (AddNumbers) in MonoDevelop (preparing for code commenting)
 
Search WWH ::




Custom Search