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

Communication among classes

Up until now, we've described classes and, by extension, Unity components, as separate standalone entities; in reality, they are deeply intertwined. You'd be hard-pressed to create any kind of meaningful software application without invoking some kind of interaction or communication between classes.

If you remember the post-office example from earlier, the example code made use of periods (or dots) to reference classes, variables, and methods. If you think of classes as directories of information, then dot notation is the indexing tool: 

PostOffice.Address

Any variables, methods, or other data types within a class can be accessed with dot notation. This applies to nested, or subclass information as well, but we'll tackle all those subjects when we get to Chapter 5, Working with Classes and Object-Oriented Programming

Dot notation is also what drives communication between classes. Whenever a class needs information about another class or wants to execute one of its methods, dot notation is used:

PostOffice.DeliverMail()

Dot notation is sometimes referred to as (.) Operator, so don't be thrown off if you see it mentioned this way in the documentation.

If dot notation doesn't quite click with you yet, don't worry, it will. It's the bloodstream of the entire programming body, carrying information and context wherever it's needed.

主站蜘蛛池模板: 周口市| 蚌埠市| 恩平市| 藁城市| 巧家县| 保山市| 习水县| 海南省| 高要市| 彰化县| 高要市| 庆安县| 南华县| 石门县| 车险| 浦县| 龙江县| 曲松县| 临安市| 陆河县| 沈阳市| 大悟县| 弥勒县| 镇宁| 九江县| 武威市| 高阳县| 罗源县| 来宾市| 镇远县| 赞皇县| 余姚市| 苏州市| 平原县| 嫩江县| 长垣县| 乐山市| 资兴市| 永福县| 娄底市| 扬州市|