Game Development Reference
In-Depth Information
3.
Select the Main Camera, and reassure yourself that it has a Camera
component.
4.
Select the bench or any of the other objects with the Variables Test
component.
5.
Drag the Main Camera onto its The View field.
This time, the objects drops nicely into place (Figure 5-18 ).
Figure 5-18. Main Camera as the value of the The View parameter
You will notice that the difference between the GameObject and the Camera variable type is that
because the name of the gameObject (which, you may remember, is a variable of the parent class,
Object) is what is shown in the field, the component type, Camera, is also shown in parentheses for
clarification.
So now you have one piece of the variable type puzzle left. You have created a script which is
essentially a class and becomes a component when it is added to a gameObject. But because it is
a new class that you have created, it does not exist in the Unity engine class libraries. To use it, you
will specify the name of the script, but it will not turn blue as the known Unity types do.
6.
Add the following variable beneath the others, and save the script:
public VariablesTest myCustomScript;
The custom type in the script (Figure 5-19 ).
 
Search WWH ::




Custom Search