Unity编辑器 RequireComponent

含义:[RequireComponent(typeof())] 为游戏物体添加某组件
举例:脚本类名前,加[RequireComponent(typeof(Rigidbody))],脚本所在游戏物体,就会有Rigidbody组件(即使场景不运行)
注意:无需引入UnityEditor命名空间
在这里插入图片描述
请添加图片描述

猜你喜欢

转载自blog.csdn.net/weixin_42935398/article/details/124119968