官术网_书友最值得收藏!

Where you declare a variable is important

You will be declaring and using variables in many places in a script. The variables that I have shown you so far are called member variables. They are members of the LearningScript class—not declared within any method. These member variables are the only variables that have the option of being displayed in the Inspector panel or being accessed by other scripts.

Note

Declaring your member variables at the beginning of a class may give you a mental clue that these member variables can be used anywhere in the script.

We will also be creating variables in methods. These variables are called local variables. They are never displayed in the Unity's Inspector panel, nor can they be accessed by other scripts. This brings us to another concept of programming, called variable scope.

主站蜘蛛池模板: 商城县| 介休市| 佳木斯市| 独山县| 枣阳市| 阿坝县| 牙克石市| 遂川县| 余干县| 松溪县| 青州市| 乐安县| 新安县| 襄樊市| 海伦市| 新巴尔虎右旗| 蒙山县| 陆良县| 江门市| 莱州市| 安康市| 巫溪县| 砚山县| 德格县| 益阳市| 涡阳县| 花莲县| 施甸县| 新乡县| 阿瓦提县| 廉江市| 罗城| 万盛区| 沁源县| 内江市| 易门县| 鄂托克旗| 和龙市| 彭山县| 磴口县| 漳州市|