Game Development Reference
In-Depth Information
The double backslash at the front of any text tells the engine not to evaluate anything after the // on
the line. The text in the script editor goes green to indicate to you that the text will be ignored.
Another typical use for the double backslash is to “comment out” code during testing. This gives you
a quick way to disable code without deleting it.
Let's go ahead and add a few comments to the variables in your script. The existing comments are
designed to introduce the functions below them, but comments can also be put at the end of a line
of code. You will see them in both places, but the goal is to keep things easy to read.
1.
Add comments so your variables code reads as follows:
public int legs = 4; // number of legs, will need to calculate speed
public float earLength = 2.5f; // will need to calculate hearing distance
public string description = ""; // will need for mouseover text
public bool IsWarmBlooded; // also needed for speed calculation
public GameObject favoriteFood; // objects that will be eaten within range
public Camera theView; // a test for a Unity component
public VariablesTest myCustomScript; // a test for a custom component
2.
Save the script.
The new addition will not affect the functionality of the script, but now makes it more understandable
(Figure 5-20 ).
Figure 5-20. The new comments in the script
Search WWH ::




Custom Search