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

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.

主站蜘蛛池模板: 平山县| 彭阳县| 松原市| 山阴县| 黄石市| 康乐县| 成安县| 綦江县| 和平区| 新乡县| 皮山县| 准格尔旗| 德江县| 桃园市| 曲阜市| 仁寿县| 互助| 右玉县| 河北省| 基隆市| 安塞县| 镇远县| 应用必备| 安阳市| 蒙城县| 治多县| 英德市| 浮梁县| 梨树县| 德格县| 安阳县| 彭水| 神农架林区| 驻马店市| 威宁| 瓮安县| 曲阳县| 苍山县| 尼木县| 吉首市| 修武县|