以下是在使用 Unity 编写脚本时将要使用的一些最重要的类。这些类涵盖 Unity 脚本化系统的一些核心领域,为查找可用的函数和事件提供了良好的起点。
类: | 描述: |
---|---|
MonoBehaviour | 所有新 Unity 脚本的基类,MonoBehaviour 引用提供了附加到游戏对象的标准脚本可以使用的所有函数和事件的列表。如果需要对游戏中的各个对象进行任何类型的交互或控制,请使用此类。 |
Transform | 每个游戏对象都在空间(无论是 3D 还是 2D 空间)中具有位置、旋转和缩放,而这些信息由变换组件表示。除了提供这些信息之外,变换组件还有许多有用的函数可用于移动、缩放、旋转、重新父子化和操纵对象,并可将坐标从一个空间转换为另一个空间。 |
Rigidbody / Rigidbody2D | 对于大多数游戏元素,物理引擎提供了最简单的工具集来移动对象、检测触发器和碰撞以及施加作用力。Rigidbody 类(或其 2D 等效类 Rigidbody2D)提供了设定速度、质量、阻力、力、扭矩、碰撞等所需的所有属性和函数。 |
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.