RequireComponent 需要组件
来源:互联网 发布:数据库规范化理论 编辑:程序博客网 时间:2024/06/06 13:56
RequireComponent 需要组件
Inherits from Attribute
The RequireComponent attribute lets automatically add required component as a dependency.
RequireComponent属性可以允许自动添加需要的组件作为一个附属。
When you add a script which uses RequireComponent, the required component will automatically be added to the game object. This is useful to avoid setup errors. For example a script might require that a rigid body is always added to the same game object. Using RequireComponent this will be done automatically, thus you can never get the setup wrong.
当你添加的一个用了RequireComponent组件的脚本,需要的组件将会自动被添加到game object(游戏物体)。这个可以有效的避免组装错误。举个例子一个脚本可能需要刚体总是被添加在相同的game object(游戏物体)上。用RequireComponent属性的话,这个过程将被自动完成,因此你可以永远不会犯组装错误。
// Mark the PlayerScript as requiring a rigidbody in the game object.// 标记PlayerScript在游戏物体必需一个刚体@script RequireComponent(Rigidbody)function FixedUpdate() {rigidbody.AddForce(Vector3.up);}
C# Example:
[RequireComponent (typeof (Rigidbody))]class PlayerScript : MonoBehaviour {void FixedUpdate() {rigidbody.AddForce(Vector3.up);}}
Constructors构造器
- RequireComponent
Require a single component
需要单个组件。
- RequireComponent 需要组件
- RequireComponent需要组件与Quaternion 四元数
- RequireComponent的使用: 当你添加的一个用了RequireComponent组件的脚本,需要的组件将会自动被添加到game object(游戏物体)。这个可以有效的避免组装错误
- RequireComponent的使用
- RequireComponent的使用
- Unity3D之RequireComponent()
- RequireComponent的使用
- 组件为什么需要注册?
- Unity3d 编辑器扩展系列-RequireComponent
- 组件需要容器的帮助
- [ExecuteInEditMode] 和 [RequireComponent(typeof(UIRoot))]理解
- Unity编辑器扩展之RequireComponent等详解
- AJAX需要组件技术作为支撑
- SCA组件运行需要设置的参数
- chapter 6.1: driver 需要的组件
- OFFICE2016仅安装需要的组件
- lzg_ad:打印机需要的组件支持
- 微服务平台:[仍然]需要一些组件
- 在eclipse中使用maven搭建web项目
- js 类与constructor属性
- error occurred during initialization of vm java/lang/noclassdeffounderror java/lang/object
- C语言 数组
- 解决CircleImageView不能用Afinal的FinalBitmap加载网络图片问题
- RequireComponent 需要组件
- 人脸检测研究2015最新进展(持续更新)
- 闪回日志 自动删除 实验记录
- 网站浏览器来路判断进行站点切换
- 黑马程序员_java判断与循环语句
- Ubuntu15.04 C语言操作Redis
- 浅析计算机网络(2) -- DNS工作原理
- 简单逆向分析使用案例(7)--Reverse001.exe 获取密码
- spring框架详解视频