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

Introducing the class

The class plays a major role in Unity. In fact, what Unity does with a class a little piece of magic when Unity creates Components.

You just learned about variables and methods. These two items are the building blocks used to build Unity scripts. The term script is used everywhere in discussions and documents. Look it up in the dictionary and it can be generally described as written text. Sure enough, that's what we have. However, since we aren't just writing a screenplay or passing a note to someone, we need to learn the actual terms used in programming.

Unity calls the code it creates a C# script. However, people like me have to teach you some basic programming skills and tell you that a script is really a class.

Note

In the previous section about methods, we created a class (script) called LearningScript. It contained a couple of variables and a method. The main concept or idea of a class is that it's a container of data, stored in variables, and methods that process that data in some fashion. Because I don't have to constantly write class (script), I will be using the word script most of the time. However, I will also be using class when getting more specific with C#. Just remember that a script is a class that is attached to a GameObject.

In Chapter 7, Creating the Gameplay is Just a Part of the Game, we will be creating some classes for a State Machine. These classes will not be attached to any GameObjects, so I won't be calling them scripts.

主站蜘蛛池模板: 通河县| 凤翔县| 固安县| 留坝县| 柳林县| 金山区| 象山县| 柳林县| 伊吾县| 宜宾市| 朝阳市| 呼伦贝尔市| 聂荣县| 正阳县| 肃宁县| 晋江市| 读书| 庄河市| 常德市| 滨海县| 玉门市| 句容市| 肇州县| 修文县| 呼和浩特市| 宾阳县| 昌都县| 金沙县| 马龙县| 南木林县| 湟源县| 廊坊市| 顺平县| 吴川市| 广州市| 兰溪市| 明溪县| 和林格尔县| 马公市| 阳曲县| 建平县|