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

Creating a variable and seeing how it works

Now using a different method, we are going to develop a script that shows us the result on the Unity console. Once again, don't be concerned about the details of how to write this; we are going to explain everything in more detail in future chapters. Just make sure that your script is the same as the script shown in the next screenshot:

  1. In the Unity Project panel, double-click variableScript. The MonoDevelop window should open automatically on variableScript.cs.
  2. In MonoDevelop, erase what we have done before and write the lines 7, 12, and 14, as shown in the following screenshot:
  1. Save the file.

The best way to save your script is by using a shortcut. If you are using a Mac, use command + S, and on Windows use CtrlS. We will be saving a new version of the script every time some changes are made to it, so it is a good idea to use a shortcut instead of saving through the File menu.

We have added a few lines to our script. Before we check whether it works or what it actually does, let's go through line 7:

public int myNumber = 9; 

In simple words, this line declares a new number type variable named myNumber
and assigns a value of 9 to it. We don't want to worry about theory too much now and want to write more code, right? Agreed, but we do need to remember a few things first.

主站蜘蛛池模板: 二连浩特市| 松潘县| 凭祥市| 石河子市| 凌海市| 页游| 博白县| 武胜县| 庆阳市| 聊城市| 家居| 广州市| 万荣县| 太白县| 南康市| 静乐县| 鹤庆县| 拉萨市| 诸暨市| 措美县| 阳山县| 山丹县| 新河县| 东阿县| 安顺市| 泾源县| 晴隆县| 环江| 德昌县| 新和县| 武邑县| 宜城市| 灵寿县| 绍兴市| 遵义县| 绍兴市| 兴化市| 临安市| 桐乡市| 全州县| 余江县|