Unity2019.3API教程(四)Component类

Component类

1. 官方定义
class in UnityEngine/Inherits from:Object/Implemented in:UnityEngine.CoreModule
属于UnityEngine命名空间下,继承自Object类,与之前的Object类和GameObject类一样属于核心模块。

2. 官方描述
Base class for everything attached to GameObjects.
Note that your code will never directly create a Component. Instead, you write script code, and attach the script to a GameObject. See Also: ScriptableObject as a way to create scripts that do not attach to any GameObject.
此类要对比下GameObject类,GameObject类是场景中所有实体的基类,而Component类是挂载在实体身上所有组件的基类,官方强调脚本是一个组件,但是脚本不可以直接挂载到实体上,当然官方介绍的ScriptableObject类是一种不附加到实体上的方法,后续再做介绍。

3. 属性
gameObject:The game object this component is attached to. A component is always attached to a gameobject.
语法:public GameObject gameObject;
获取自身物体,Component类比较特殊,除了gameobjec

评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值