Game Development Reference
In-Depth Information
Note As we'll see later, you can access an Object's tag through the Unity API with the GameObject.tag
property. You can also compare a tag with a String value using the GameObject.CompareTag function.
See http://docs.unity3d.com/Documentation/ ScriptReference/GameObject-tag.html and
http://docs.unity3d.com/ Documentation/ScriptReference/GameObject.CompareTag.html .
Layers. Layers are functionally similar to tags in that they mark or group
GameObjects together by a specific criterion. Tags, however, are typically used to
select or identify objects in script , as we'll see later. In contrast, layers are typically
(though not always) used in conjunction with cameras. By assigning a
group of GameObjects onto a layer, you can tell a camera to selectively render
or ignore a layer, and thereby all objects on that layer; so layers are especially
convenient if you have objects that must be shown or hidden together—like GUI
menus and HUD elements. Layers are further considered in Chapter 8.
Note If you're hungry for more information on Layers right now , you can check out the Unity Layer
documentation at http://docs.unity3d.com/Documentation/Components/Layers.html .
Use concise code comments. The final organization tip to mention concerns
code comments: that is, human readable statements that accompany source
code and clarify what the code actually does. In C#, code comments are written
with the // or /* */ syntax. You can also use a XML commenting style with
MonoDevelop (more information is at http://unitypatterns.com/xml-comments/ ) .
My advice is: use code comments. They make life much easier—when written
concisely! It's common to hear criticism of code commenting, for various
reasons. The following lists two of them, and I provide a reasoned response to
illustrate the importance of commenting.
Criticism 1: I don't need to write code comments because I know what I'm
doing. I know what this code does. And besides, nobody else is probably
ever going to read my code anyway.
Response: The core assumption here is that code comments are exclusively
for the benefit of other people. But this is not true. Code comments can help
you write down and clarify your own ideas. They can help you remember
what your own code is doing when you return to it weeks or months later.
You may know what your own code is doing right now , but it'll not be so
fresh in your mind after weeks and months pass without having seen it. So
use code comments as an aid to memory.
 
Search WWH ::




Custom Search