Game Development Reference
In-Depth Information
Press +S to save, then return to the Unity editor. In the Project panel, select the Console tab. This
is where you will see the output appear as a result of the code you just wrote. In the Game view,
make sure Maximize on Play is deselected so it won't obscure the Console. Now go and click Play.
In the Console view, you will see “Hello World!” appear—yay! (See Figure 2-15 .)
Figure 2-15. “Hello World!” print output in the Console panel
Another way to print messages to the Console is by using Debug.Log . “Debugging” is the process of
finding and correcting errors known as “bugs” in your code. You will learn more about how to use
the Debug class and its functions in Chapter 10. Change your line of code to look like this:
function Start () {
Debug.Log("Hello World!");
}
Save, run in the Unity editor by clicking Play, and look in the Console to see that you get the same
“Hello World!” followed by a slightly different commentary (Figure 2-16 ).
Figure 2-16. Hello World! Debug.Log output in the Console panel.
Game development is a constant learning process. The folks at Unity are continually adding
new capabilities and new platforms to which you can port your games. Even the most seasoned
developer must keep up with the latest changes and additions, most commonly by referring to the
provided documentation. Each new game project likely has something you may not be familiar
with or that you may want to double-check for changes. Just as you will learn UnityScript best
by creating the examples from this topic in Unity and MonoDevelop yourself, you will get used to
referring to the documentation most quickly by using it.
Stop the game and go back to the script in MonoDevelop. ( +Tab is a nice shortcut for when you
are working between two windows.) Click anywhere on the word Debug, then press +' to open the
Debug.Log scripting reference in your web browser (Figure 2-17 ).
 
Search WWH ::




Custom Search