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

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.

主站蜘蛛池模板: 九龙城区| 泽库县| 蓬安县| 德兴市| 黎川县| 和硕县| 观塘区| 闵行区| 正蓝旗| 凤翔县| 通州市| 彭泽县| 平和县| 宝丰县| 庆城县| 托克逊县| 恭城| 驻马店市| 寿光市| 彰武县| 镶黄旗| 武陟县| 香河县| 华蓥市| 启东市| 西畴县| 微山县| 乐陵市| 阿拉尔市| 邓州市| 台东县| 长沙县| 昭觉县| 新闻| 新蔡县| 辛集市| 承德县| 望城县| 当雄县| 长治市| 邳州市|