Game Development Reference
In-Depth Information
Figure 5-27. The three messages in the console
If you left off the quotation marks around the message and saved the script, you would get an error
message that reads “The name 'Hello' does not exist in the current context.” But if you replace it
with one of your variables, everything is good.
Replace the Debug.Log line with
Debug.Log(legs);
4.
5. Save the script, and click Play.
This time you can see the different legs values you entered in the Inspector for each of the three
gameObjects (Figure 5-28 ).
Figure 5-28. The three Legs parameter values
The problem with having the value of the variable printed out is that it is rather cryptic. Fortunately,
you can have the best of both character strings and variables.
6.
Change the line to
Debug.Log("This object has " + legs + " legs.");
7.
Save the script, and click Play.
This time, it is less cryptic (Figure 5-29 ), but it could be better.
Search WWH ::




Custom Search