- Learning C# 7 By Developing Games with Unity 2017(Third Edition)
- Micael DaGra?a Greg Lukosek
- 257字
- 2021-07-02 19:59:37
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:
- In the Unity Project panel, double-click variableScript. The MonoDevelop window should open automatically on variableScript.cs.
- In MonoDevelop, erase what we have done before and write the lines 7, 12, and 14, as shown in the following screenshot:

- 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 Ctrl + S. 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.
- Oracle從入門到精通(第3版)
- Android應用程序開發與典型案例
- 零基礎學C++程序設計
- C# Programming Cookbook
- 神經網絡編程實戰:Java語言實現(原書第2版)
- 三維圖形化C++趣味編程
- Learning jQuery(Fourth Edition)
- Oracle數據庫編程經典300例
- Python計算機視覺和自然語言處理
- Learning D
- Learning Image Processing with OpenCV
- 信息學奧林匹克競賽初賽精講精練
- Java網絡編程實用精解
- Web前端開發全程實戰:HTML5+CSS3+JavaScript+jQuery+Bootstrap
- 給產品經理講技術