一个__游戏对象__包含多个__组件__。(请参阅关于游戏对象的文档以了解更多信息。)
下面使用最常见的__组件__(即__变换组件__)来举例说明__游戏对象__和__组件__之间的关系。
可以通过在 Inspector 中查看新的__游戏对象__来查看__变换组件__:
请注意,新的空__游戏对象__包含一个名称 (“GameObject”)、一个 Tag (“Untagged”) 和一个 Layer (“Default”)。它还包含一个__变换组件__。
在 Editor 中无法创建不含__变换组件__的__游戏对象。此组件定义__游戏对象__在游戏世界和 Scene 视图__中的位置、旋转和缩放。
__变换组件__还支持名为“父子化”的概念,这一概念对于使用__游戏对象__很重要。要详细了解__变换组件__和父子化,请参阅变换组件参考页面。
变换组件__对于所有__游戏对象__都至关重要,因此每个__游戏对象__都有一个变换组件,但__游戏对象__还可以包含其他__组件。
默认情况下,每个场景都有一个__主摄像机 (Main Camera)__ 游戏对象。主摄像机具有若干__组件。(要查看此信息,请在打开的__场景__中选择主摄像机来查看其 Inspector__。)
通过查看__主摄像机 (Main Camera)__ 游戏对象__的 Inspector__,可以看到其包含额外__组件__。具体来说,包括 Camera 组件、GUILayer、Flare Layer 和 Audio Listener。所有这些__组件__都为此__游戏对象__提供功能。
还可以向__游戏对象__中添加 Rigidbody、Collider、Particle System 和 Audio 等各种不同的__组件__。
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.