- Learning C# 7 By Developing Games with Unity 2017(Third Edition)
- Micael DaGra?a Greg Lukosek
- 176字
- 2021-07-02 19:59:37
Changing variables
Since myNumber is a variable, the value that it stores can vary. If we change what is stored in it, the answer to the equation will also change. Follow these steps:
- Stop Unity by pressing the Stop button and change 9 to 19 in the Unity Inspector tab
- Notice that when you restart the game, the answer will be 30
I bet you have noticed the public keyword at the very beginning of the line that declares the myNumber variable. Let me explain what it means. It's called an access modifier. We use these to specify the accessibility of a variable. The public keyword means that the variable can be seen by code outside our script. Look again at the Unity Inspector tab. You can see the value of myNumber there because it is public. The private keyword, however, means that the variable can be accessed only by code in the same class.
Private variables are not visible in the Unity Inspector tab. If you wish to control or view them, make them public.
- .NET之美:.NET關鍵技術深入解析
- Learn TypeScript 3 by Building Web Applications
- MySQL 8從入門到精通(視頻教學版)
- Web交互界面設計與制作(微課版)
- 機器人Python青少年編程開發實例
- Building a Quadcopter with Arduino
- 精通網絡視頻核心開發技術
- 區塊鏈底層設計Java實戰
- 執劍而舞:用代碼創作藝術
- Python大學實用教程
- 小程序從0到1:微信全棧工程師一本通
- Drupal 8 Development Cookbook(Second Edition)
- 3D Printing Designs:Octopus Pencil Holder
- 優化驅動的設計方法
- React and React Native