当前位置:网站首页>Editor extensions in unity
Editor extensions in unity
2022-07-05 22:28:00 【M.JH】
Catalog
1.RequireComponent
effect : You can ensure that the object on which the script is mounted contains the specified components
usage :
[RequireComponent(typeof(BoxCollider))]
public class Test : MonoBehaviour
{
// Ensure that the attached objects have BoxCollider Components
}
2.AddComponentMenu
effect : You can add a new category when adding components
usage :
[AddComponentMenu(“MJH/Test”)]
public class Test : MonoBehaviour
{
}
3.CreateAssetMenu
effect : You can create objects in file resources , General coordination ScriptObject Use it together
usage :
[CreateAssetMenu(fileName =“My Object”,menuName = “ScriptableObject/NewTab”, order = 1)]
public class Test : ScriptableObject
{
}
4.DisallowMultipleComponent
effect : Prevent us from adding scripts to the same object repeatedly
usage :
[DisallowMultipleComponent]
public class Test : MonoBehaviour
{
}
5.SerializeField
effect : You can serialize fields on the editor , Let developers assign values to fields in the editor
usage :
public class Test : MonoBehaviour
{
[SerializeField] private string str;
}
6.System.Serializable
effect : You can serialize structures or classes on the editor , Let developers assign values to fields in the editor
usage :
public class Test : MonoBehaviour
{
public PlayerStats playerStats;
[System.Serializable] public struct PlayerStats
{
public int a;
public int b;
public bool YN;
}
}
7.HideInInspector
effect : Public fields can be hidden Do not serialize the display on the editor
usage :
public class Test : MonoBehaviour
{
[HideInInspector] public string str;
}
8.Tooltip
effect : You can add hints for fields in the editor
usage :
public class Test : MonoBehaviour
{
[Tooltip(“ Player name ”)]
public string PlayerName;
}
9.Multiline
effect : You can enlarge the field input box in the editor
usage :
public class Test : MonoBehaviour
{
[Multiline(4)]
public string PlayerName;
}
10.Space
effect : You can adjust the spacing between fields in the editor
usage :
public class Test : MonoBehaviour
{
public string PlayerName;
[Space(50)]
public string EnemyName;
}
11.TextArea
effect : Add a slider that pulls up and down for the editor field input box
usage :
public class Test : MonoBehaviour
{
[TextArea]
public string PlayerName;
}
12.Header
effect : Add a dividing line in the editor
usage :
public class Test : MonoBehaviour
{
[Header(“Player Setting”)]
public string PlayerName;
public int PlayerHp;
[Header(“UI Setting”)]
public string UIsetting;
public string UI2setting;
}
13.Range
effect : Add a range to the variable
usage :
public class Test : MonoBehaviour
{
[Range(0, 1)] public float Speed;
}
14.Min
effect : Set the minimum value of the variable
usage :
public class Test : MonoBehaviour
{
[Min(0)] public float Speed;
}
15.ContextMenu
effect : Execute the function when it is not running , For example, functions such as restoring the position of objects
usage :
public class Test : MonoBehaviour
{
[SerializeField] private GameObject ball;
[ContextMenu(“Do things”)]
public void ResetBall()
{
ball.transform.position = Vector3.zero;
}
}
边栏推荐
- What changes has Web3 brought to the Internet?
- Granularity of blocking of concurrency control
- Interview questions for famous enterprises: Coins represent a given value
- FBO and RBO disappeared in webgpu
- Leetcode simple question ring and rod
- Performance monitoring of database tuning solutions
- What about data leakage? " Watson k'7 moves to eliminate security threats
- 如何快速体验OneOS
- What if win11 is missing a DLL file? Win11 system cannot find DLL file repair method
- Three "factions" in the metauniverse
猜你喜欢
Metaverse Ape获Negentropy Capital种子轮融资350万美元
Analysis of the problem that the cookie value in PHP contains a plus sign (+) and becomes a space
Livelocks and deadlocks of concurrency control
Oracle triggers
Navigation day answer applet: preliminary competition of navigation knowledge competition
A substring with a length of three and different characters in the leetcode simple question
Metaverse Ape上线倒计时,推荐活动火爆进行
科技云报道荣膺全球云计算大会“云鼎奖”2013-2022十周年特别贡献奖
航海日答题小程序之航海知识竞赛初赛
The statistics of leetcode simple question is the public string that has appeared once
随机推荐
Metasploit(msf)利用ms17_010(永恒之蓝)出现Encoding::UndefinedConversionError问题
Sparse array [matrix]
等到产业互联网时代真正发展成熟,我们将会看待一系列的新产业巨头的出现
Practice: fabric user certificate revocation operation process
如何快速体验OneOS
Serializability of concurrent scheduling
Nacos installation and service registration
Common interview questions of JVM manufacturers
CA certificate trampled pit
Damn, window in ie open()
Assign the output of a command to a variable [repeat] - assigning the output of a command to a variable [duplicate]
The statistics of leetcode simple question is the public string that has appeared once
[Chongqing Guangdong education] National Open University autumn 2018 0088-21t Insurance Introduction reference questions
The simple problem of leetcode is to split a string into several groups of length K
Binary tree (III) -- heap sort optimization, top k problem
How to reverse a string fromCharCode? - How to reverse String. fromCharCode?
南京:全面启用商品房买卖电子合同
Matlab draws a cute fat doll
boundary IoU 的计算方式
The difference between MVVM and MVC