Game Development Reference
In-Depth Information
The code sample 2-1 generates two compile-time errors, as shown in the following
screenshot. These happen because lines 11 and 16 refer to the variable
mynumber
that
doesn't exist, although
MyNumber
does (case sensitivity). Compile-time errors such
as these are critical because they render your code invalid. This means you cannot
compile your code and run your game until the errors are corrected.
Viewing compilation errors in the Console window
If compilation errors are not shown in
Console
as expected, then make sure that the
errors filter is enabled. To enable this, click on the error filter icon (a red exclamation
mark icon) in the top-right corner of the
Console
window. The
Console
window
features three filters, comments (
A
), warnings (
B
), and errors (
C
), as shown in the
following screenshot, to hide and show specific messages. These toggle the visibility
of each message type in the
Console
window. Comments refer to the messages that
you, as a programmer, explicitly print to the
Console
window from your code using
the
Debug.Log
statement. We'll see examples of this shortly (you can also use the
Print
function). Warnings refer to potential issues or wastages detected in your
code. These are syntactically valid and will compile even if ignored by you, but they
might cause problems or have unintended and wasteful results. Errors refer to any
compile-time errors found in your code that affect its compilation validity, such as
with code sample 2-1.
Enabling/disabling the Console window filters