- Learning C# 7 By Developing Games with Unity 2017(Third Edition)
- Micael DaGra?a Greg Lukosek
- 361字
- 2021-07-02 19:59:38
Using the term "method" instead of "function"
You are going to see the words "function" and "method" used everywhere as you learn how to code.
The words "function" and "method" truly mean the same thing in Unity. They also do the same thing.
Since you are studying C#, and C# is an Object–Oriented Programming (OOP) language, I will use the word method throughout this book, just to be consistent with C# guidelines. It makes sense to learn the correct terminology for C#. The authors of Scripting Reference probably should have used the word "method" instead of "function" in all of their documentation. Anyway! Whenever you hear either of these words, remember that they both mean the same thing.
From now on, I'm going to use the word method or methods in this book. When I refer to the functions shown in Scripting Reference, I'm going to use the word "method" instead, just to be consistent.
We're going to edit the variableScript again. In the following screenshot, there are a few lines of code that look strange. We are not going to get into the details of what they mean in this chapter. We will discuss that in Chapter 4, Getting into the Details
of Methods. Right now, I am just showing you a method's basic structure and how it works:
- In MonoDevelop, select variableScript for editing
- Edit the file so that it looks exactly like what is shown in the following screenshot:

- Save the file
In the previous screenshot, lines 6 and 7 will look familiar to you. They are variables, just as you learned in the previous section. There are two of them this time. These variables store the numbers that are going to be added.
Line 16 may look very strange to you. Don't concern yourself right now with how it works. Just know that it's a line of code that lets the script know when the Enter key is pressed. On the keyboard method, AddTwoNumbers will be called into action.
The simplest way to call a function in your code is by using its name followed by brackets and a semicolon, for example, AddTwoNumbers();.
- iOS 9 Game Development Essentials
- 神經(jīng)網(wǎng)絡編程實戰(zhàn):Java語言實現(xiàn)(原書第2版)
- 軟件測試工程師面試秘籍
- Java程序員面試算法寶典
- 信息安全技術(shù)
- Getting Started with Laravel 4
- Mastering C++ Multithreading
- 智能手機APP UI設計與應用任務教程
- Python 3.7從入門到精通(視頻教學版)
- Laravel Application Development Blueprints
- Fastdata Processing with Spark
- Python 3 Object:oriented Programming(Second Edition)
- Visual Basic 程序設計實踐教程
- Python預測分析與機器學習
- Node.js實戰(zhàn):分布式系統(tǒng)中的后端服務開發(fā)