当前位置:网站首页>关于Unity Inspector上的一些常用技巧,一般用于编辑器扩展或者其他
关于Unity Inspector上的一些常用技巧,一般用于编辑器扩展或者其他
2022-07-06 04:49:00 【charlsdm】
RequireComponent
RequireComponent用于给Object添加必要的组件,也可以理解为通过代码代替“Add Component”的操作,能够有效避免由于忘记添加必要的组件而造成的报错,同时也适用于为多个Object添加相同组件的场景,省去了重复操作。
另外RequireComponent代码需要放在类的前面
[RequireComponent(typeof(Rigidbody))]
[RequireComponent(typeof(AudioSource))]
需要注意的是,当要移除通过RequireComponent添加的组件时,需要先移除脚本,否则产生如下警告。
Range
Range为变量限定取值范围,但仅限于在Inspector窗口中,也就是说,通过代码改变变量的值是不受Range约束的
[Range(1, 5)]
public int Speed;
[Range(0,1)]
public float Time;
Space
Space使Inspector窗口中字段之间的间隔增大
public float Max;
public float Min;
[Space()]
public float Speed;
SerializeField
一般来说,只有public的变量才会显示在Inspector窗口中,但SerializeField可以忽略访问修饰符,使private的变量也能显示
private bool NotInInspector;
[SerializeField] private bool InInspector;
HideInInspector
使public的字段不显示在Inspector窗口中
[HideInInspector]
public float Hide;
public float notHide;
Tooltip
为Inspcetor窗口中的字段附加一段文字说明
[Tooltip("Health value between 0 and 100.")]
public int Health = 100;
Header
给Inspector字段加标题,实现分组
[Header(“Text”)]
public Text hp;
public Text mp;
public Text power;
public Text defense;
边栏推荐
- Why does MySQL need two-phase commit
- 比尔·盖茨晒18岁个人简历,48年前期望年薪1.2万美元
- ue5 小知识点 开启lumen的设置
- 【LGR-109】洛谷 5 月月赛 II & Windy Round 6
- The implementation of the maize negotiable digital warehouse receipt standard will speed up the asset digitization process of the industry
- Redis has four methods for checking big keys, which are necessary for optimization
- On the solution of es8316's audio burst
- What should the project manager do if there is something wrong with team collaboration?
- 程序员在互联网行业的地位 | 每日趣闻
- 你需要知道的 TCP 三次握手
猜你喜欢
The IPO of mesk Electronics was terminated: Henan assets, which was once intended to raise 800 million yuan, was a shareholder
ORM aggregate query and native database operation
[lgr-109] Luogu may race II & windy round 6
CADD course learning (7) -- Simulation of target and small molecule interaction (flexible docking autodock)
Coreldraw2022 new version new function introduction cdr2022
Crazy God said redis notes
Delete subsequence < daily question >
程序员在互联网行业的地位 | 每日趣闻
Vulnerability discovery - vulnerability probe type utilization and repair of web applications
canal同步mysql数据变化到kafka(centos部署)
随机推荐
Word cover underline
Quatre méthodes de redis pour dépanner les grandes clés sont nécessaires pour optimiser
ue5 小知识 FreezeRendering 查看视锥内渲染的物体
ISP学习(2)
Bill Gates posted his 18-year-old resume and expected an annual salary of $12000 48 years ago
2021 robocom world robot developer competition - undergraduate group (semi-finals)
8. Static file
饼干(考试版)
Digital children < daily question> (Digital DP)
麦斯克电子IPO被终止:曾拟募资8亿 河南资产是股东
Project manager, can you draw prototypes? Does the project manager need to do product design?
Redis 排查大 key 的4种方法,优化必备
Excellent PM must experience these three levels of transformation!
Postman manage test cases
关于es8316的音频爆破音的解决
I'd like to ask about the current MySQL CDC design. In the full volume phase, if a chunk's binlog backfill phase,
力扣(LeetCode)186. 翻转字符串里的单词 II(2022.07.05)
Postman assertion
How does vs change the project type?
English Vocabulary - life scene memory method