Game Development Reference
In-Depth Information
Should a variable remain private or exposed? If you only require the
value in the variable inside a single script file, then private is fine, as
long as you don't want to be able to change the values of the variables
in the Inspector. If at some stage you need to access the value of a
variable from another JavaScript file, which is covered later in the topic,
the variable needs to be exposed. The author's advice is to keep the
variable private until absolutely necessary—that way you can mess
around with setting its values in the code file and you don't need
to keep resetting the script in the Inspector.
Step 11. Switch back to the script editor. Take a look at where the
value of objScaleX is being used. It is changing the X value of the
Scale in the Transform component of the GameObject the script is
attached to, which in this case is the cube. This linkage is illustrated
in Figure 1.27 showing Unity in play mode and the modified X scale
in the Inspector.
Fig 1.27 How script links to the
values of components attached
to Game Objects.
Search Nedrilad ::

Custom Search