当前位置:网站首页>[RequireComponent(typeof(....))]
[RequireComponent(typeof(....))]
2022-07-26 21:16:00 【unity工具人】
当某个脚本必须依赖其他脚本或者组件共同使用时,为了避免人为添加过程的操作失误,可以在代码中使用RequireComponent,它的作用就是添加该脚本时,会自动将所依赖的各个组件添加至gameobject上,避免人为操作的失误。
例:
[RequireComponent(typeof(Image))]
public class Person : MonoBehaviour
{
}
为物体挂载该脚本时Image组件将自动添加在物体的Inspector面板
边栏推荐
- In depth analysis of the source code, why is the string class immutable? (hit me before you understand)
- Keyword maintenance of dream weaving document doesn't work
- 07 df 命令
- [shutter -- geTx] pop up - dialog, snackBar, bottomsheet
- It is said that Samsung obtained EUV photoresist from Belgium
- Ren Zhengfei talked about the suppression of the United States again: to live is to win, and to defeat the United States
- MOS 管示意图
- Flink's real-time data analysis practice in iFLYTEK AI marketing business
- 会用redis吗?那还不快来了解下redis protocol
- Also on Data Governance
猜你喜欢

Thoroughly understand the principle and implementation of service discovery

6、 Wechat applet release process

FreeRTOS个人笔记-事件

The principle of normal equation method and its difference from gradient descent method

带你搞懂MySQL隔离级别,两个事务同时操作同一行数据会怎样?

新来个技术总监要我做一个 IP 属地功能~

Understanding and practice of the trend of Bank of London foreign exchange

Pytorch 使用RNN模型构建人名分类器

Selenium automated test interview questions family bucket

CMake 的使用
随机推荐
[audio and video] ijkplayer player parameter description document
cmake编译obs-studio-27.2.0
Can you use redis? Then come and learn about redis protocol
Flextronics responded to the "seizure of Huawei materials" incident: deeply regretted, looking forward to continuing cooperation!
TASK04|分类分析
ansible安装及使用
吃透负载均衡
Props with type Object/Array must...
d和c的符区别
Japan approves the export of EUV photoresist to South Korea, and the crisis of Samsung and SK Hynix may be alleviated
安全浏览器“隐身”模式可以查看历史记录吗?
攻防世界----ics-07
虾皮shopee根据ID取商品详情 API
JDBC summary
Pytoch squeeze() unsqueeze() usage
js验证复杂密码
FreeRTOS personal notes - Events
[shutter -- geTx] pop up - dialog, snackBar, bottomsheet
In depth interpretation of happens before principle
npm, npm中文文档, npm学习使用