Game Development Reference
In-Depth Information
With scripting, you will be creating custom components that will act as templates that you can reuse,
not only on different objects, but in different projects as well. Unlike the imported art assets, scripts
are created inside Unity with the help of an editor. Theoretically, you could write the scripts in any
simple text editor, but using a conventional text editor designed specifically for scripting provides
you with all sorts of advantages that will help you problem-solve or debug your scripts. Unity ships
with the MonoDevelop text editor.
The Script Editor
The easiest way to create a script is through the Create menu, either from the Assets menu or by
right-clicking in the Project view. As with all project assets, it is up to you to keep them organized.
The first few scripts will be experimental, so it will be well worth making a folder to keep them
separate from the rest of your game assets.
1.
Create a new folder in the Project view with the right-click menu, or from the
Create drop-down list, “Create a Folder” option.
2.
Name the folder Test Scripts .
3.
Right-click over the new folder and, from Create, select C# Script.
A new script is created and is put immediately into rename mode (Figure 5-1 ).
Figure 5-1. The new script in the two-column view (left) or the one-column view (right)
4.
Name the new script VariablesTest .
The new script comes with a default name of NewBehaviourScript. According to the documents,
“A script makes its connection with the internal workings of Unity by implementing a class which
derives from the built-in class called MonoBehaviour”—hence, “NewBehaviourScript.” A class is a
kind of blueprint or template that allows you to define parameters and functionality in a generic way.
Because it is a component, you can then customize the object it resides on by changing the values
of its parameters.
 
Search WWH ::




Custom Search