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

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.

主站蜘蛛池模板: 兰坪| 江安县| 淄博市| 卢氏县| 于都县| 凤凰县| 大悟县| 桃源县| 卢湾区| 磐安县| 兴隆县| 毕节市| 赣州市| 元谋县| 建宁县| 彭泽县| 子洲县| 舒城县| 股票| 定南县| 闽侯县| 白山市| 五峰| 金华市| 东方市| 镇巴县| 榆中县| 宽甸| 土默特右旗| 香格里拉县| 新疆| 自贡市| 酒泉市| 铁岭市| 新巴尔虎右旗| 耒阳市| 西贡区| 秦安县| 常宁市| 锡林郭勒盟| 安庆市|