- Learning C# by Developing Games with Unity 5.x(Second Edition)
- Greg Lukosek
- 244字
- 2021-07-09 20:03:32
Components that communicate using dot syntax
Our script has variables for holding data, and our script has methods to allow tasks to be performed. I now want to introduce the concept of communicating with other GameObjects
and the components they contain. Communication between one components GameObject
and another component GameObject
using dot syntax is a vital part of scripting. It's what makes interaction possible. We need to communicate with other components or GameObjects
to be able to use the variables and methods in other components.
What's with the dots?
When you look at code written by others, you'll see words with periods separating them. What the heck is that? It looks complicated, doesn't it. The following is an example from the Unity documentation:
transform.position.x
Note
Don't concern yourself with what the preceding code means, as that comes later. I just want you to see the dots.
This is called dot syntax. The following is another example. It's the fictitious address of my house: UnitedKingdom, Bedfordshire, Sandy, 10MyStreet. Looks funny, doesn't it? That's because I used the syntax (grammar) of C# instead of the post office. However, I'll bet that, if you look closely, you can easily figure out how to find my house. We'll get into much more at a later stage. For now, think of dot syntax as an address, starting from a big thing, a country in this case, and narrowing down to the most precise part that we want to access.
- PHP 從入門到項目實踐(超值版)
- C++面向對象程序設計(微課版)
- RTC程序設計:實時音視頻權威指南
- Hands-On JavaScript High Performance
- Java 11 Cookbook
- Python編程實戰(zhàn)
- Getting Started with Hazelcast(Second Edition)
- jQuery Mobile移動應用開發(fā)實戰(zhàn)(第3版)
- Scratch趣味編程:陪孩子像搭積木一樣學編程
- Visual Studio Code 權威指南
- Orleans:構建高性能分布式Actor服務
- Cocos2d-x by Example:Beginner's Guide(Second Edition)
- 零基礎學Python編程(少兒趣味版)
- Python網絡爬蟲實例教程(視頻講解版)
- Python計算機視覺與深度學習實戰(zhàn)