Game Development Reference
In-Depth Information
Set the Sunflower's Legs parameter to 1 and the Walkway's Legs parameter
to 0 .
2.
Now you have three gameObjects using an instance of the VariablesTest script, yet the script is
customized to each one.
3.
Click Play.
Change each of the object's Legs parameters to a different integer.
4.
5.
Stop Play mode.
The values return to their original Inspector values. Most, but not all, parameters exposed in the
Inspector cannot be permanently changed during runtime. This allows you to test parameters during
runtime without the fear of breaking functionality. For times when you are experimenting to get
optimal values during runtime, you will have to remember or make note of the values you wish to
make permanent. If you find yourself forgetting you are in Play mode too often while setting values,
you can change the tint of the editor. As a default, it goes slightly darker in Play mode.
1.
From the Edit menu, Preferences, select Colors.
2.
Under General, locate Playmode Tint.
3.
Change the color to something more obvious, and click Play.
Much of the editor, with the notable exception of the Game view and Scene view, is tinted to reflect
your color choice.
4.
Back in the Preferences window, click the Use Defaults button to return the
default color.
5.
Stop Play mode.
The default color, restored during runtime, does not revert back to the color you set before you
pressed Play. Feel free to reset the color to its default or to use a color of your own choosing.
With a bit of typical Unity variable functionality investigated, it's time to check out a few more
variable types.
6.
Under your existing variable line, add the following:
public float earLength = 2.5;
public string description = "";
public bool isWarmBlooded;
public GameObject favoriteFood;
7.
Save the script.
8.
Click Play.
A message appears in the Scene view (Figure 5-6 ).
Search WWH ::




Custom Search