当前位置:网站首页>關於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;
边栏推荐
- Introduction of several RS485 isolated communication schemes
- 几种RS485隔离通讯的方案介绍
- word封面下划线
- Raspberry pie 3.5-inch white screen display connection
- 内核判断i2c地址上是否挂载外设
- Postman断言
- Postman关联
- The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
- [buuctf.reverse] 159_ [watevrCTF 2019]Watshell
- What should the project manager do if there is something wrong with team collaboration?
猜你喜欢
Why does MySQL need two-phase commit
Uva1592 Database
Distributed transaction solution
Embedded development program framework
L'introduction en bourse de MSK Electronics a pris fin: 800 millions de RMB d'actifs de Henan étaient des actionnaires
DMA use of stm32
Postman pre script - global variables and environment variables
Zynq learning notes (3) - partial reconfiguration
麥斯克電子IPO被終止:曾擬募資8億 河南資產是股東
ETCD数据库源码分析——etcdserver bootstrap初始化存储
随机推荐
On the solution of es8316's audio burst
ue5 小知识 FreezeRendering 查看视锥内渲染的物体
【LGR-109】洛谷 5 月月赛 II & Windy Round 6
[noip2009 popularization group] score line delimitation
Is the mode of education together - on campus + off campus reliable
Basic explanation of turtle module - draw curve
web工程导入了mysql驱动jar包却无法加载到驱动的问题
The implementation of the maize negotiable digital warehouse receipt standard will speed up the asset digitization process of the industry
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
[classic example] binary tree recursive structure classic topic collection @ binary tree
11. Intranet penetration and automatic refresh
Postman关联
I'd like to ask about the current MySQL CDC design. In the full volume phase, if a chunk's binlog backfill phase,
Project manager, can you draw prototypes? Does the project manager need to do product design?
Digital children < daily question> (Digital DP)
ISP学习(2)
[NOIP2008 提高组] 笨小猴
RT thread analysis - object container implementation and function
饼干(考试版)
力扣(LeetCode)186. 翻转字符串里的单词 II(2022.07.05)