Game Development Reference
In-Depth Information
The Unity Console is useful for printing and viewing debug messages
More information on the if statements, the if-else statement, and their usage in C#
can be found online at http://msdn.microsoft.com/en-GB/library/5011f09h.
aspx .
Unity Console
As you can see in the preceding screenshot, the console is a debugging
tool in Unity. It's a place where messages can be printed from the code
using the Debug.Log statement (or the Print function) to be viewed by
developers. They are helpful to diagnose issues at runtime and compile
time. If you get a compile time or runtime error, it should be listed in
the Console tab. The Console tab should be visible in the Unity Editor
by default, but it can be displayed manually by selecting Console in the
Window menu from the Unity application file menu. More information
on the Debug.Log function can be found at http://docs.unity3d.
com/ScriptReference/Debug.Log.html .
You can, of course, check for more conditions than just equality ( == ), as we did in
code sample 1-2. You can use the > and < operators to check whether a variable
is greater than or less than another value, respectively. You can also use the !=
operator to check whether a variable is not equal to another value. Further, you
can even combine multiple conditional checks into the same if statement using
the && (AND) operator and the || (OR) operator. For example, check out the
following if statement. It performs the code block between the {} braces only if the
PlayerHealth variable is between 0 and 100 and is not equal to 50 , as shown here:
if(PlayerHealth >= 0 && PlayerHealth <= 100 && PlayerHealth !=50)
{
 
Search WWH ::




Custom Search