Game Development Reference
In-Depth Information
Figure 5-6. A compiler error blocking Play mode
If you take a look at the script editor, you will see that the Document Outline is not blank. If it was,
you could expect a syntax error. Instead, the message tells you that there is a compiler error. The
script was saved but was not able to compile, so the game cannot run. You will get this error
whether or not the script is being used in the scene.
The trick here is to figure out where the problem lies. The console will often provide clues and
occasionally even suggest a solution.
The Console and Error Messages
The console is where Unity will communicate with you. It will tell you when your code has errors and
often make suggestions about what it thinks you meant to write. The message may be cryptic, but it
will also tell you where it was generated in the code. The console is also a place where you can have
messages of your own printed out, as you will find later in the chapter.
1.
Look at the status line, and check out the message it holds (Figure 5-7 ).
Figure 5-7. The error message in the status line
It tells you which script has the problem, VariablesTest.cs. It gives the line number and column
number (7, 36). It gives the error, “Literal of type double cannot be implicitly converted to type 'float.'”
And, in this case, it offers a suggestion for fixing the problem.
2.
Click on the status line to open the console, or click on the Console tab.
 
Search WWH ::




Custom Search