Game Development Reference
In-Depth Information
The following screenshot demonstrates the output of this code in Console when
attached to a cube GameObject . The Debug.Log message is printed in the main
console message list. If the message is selected with the mouse, Console will also
indicate a script file and line associated with the statement.
Debug.Log messages can convert objects to strings, and the Console window
also indicates an associated script file and line
The main limitations of Debug.Log as a debugging technique relate to code
cleanliness and program complexity. First, the Debug.Log statements require you to
explicitly add code to your source files. When you're done debugging, you'll need
to either remove the Debug.Log statements manually or leave them there, which
is wasteful and results in confusion, especially if you have to add the additional
Debug.Log statements in many other places. Second, though Debug.Log is useful
to target specific problems or monitor specific variables over time, it's ultimately
awkward to get a higher-level picture of your code and its execution to trace errors
whose presence you detect but whose location is entirely unknown. These criticisms,
however, shouldn't be regarded as advice to avoid using the Debug.Log statements
entirely. They should be considered only to use them appropriately. Debug.Log
works best when an error or problem can be traced to a prime suspect object,
and you want to observe or monitor its values to see how they change or update,
especially during events such as OnStart .
 
Search WWH ::




Custom Search