当前位置:网站首页>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;
}
}
边栏推荐
- 谷歌地图案例
- Character conversion PTA
- 抖音__ac_signature
- APK加固技术的演变,APK加固技术和不足之处
- IIC bus realizes client device
- Depth first DFS and breadth first BFS -- traversing adjacency tables
- QT creator 7 beta release
- All expansion and collapse of a-tree
- The statistics of leetcode simple question is the public string that has appeared once
- Some tutorials install the database on ubantu so as not to occupy computer memory?
猜你喜欢
Stored procedures and stored functions
Performance monitoring of database tuning solutions
Nacos installation and service registration
数博会精彩回顾 | 彰显科研实力,中创算力荣获数字化影响力企业奖
Sparse array [matrix]
Serializability of concurrent scheduling
Damn, window in ie open()
Opencv judgment points are inside and outside the polygon
Oracle triggers
Two stage locking protocol for concurrency control
随机推荐
Some tutorials install the database on ubantu so as not to occupy computer memory?
Solutions for unexplained downtime of MySQL services
Golang writes the opening chapter of selenium framework
Sub total of Pico development
Leetcode simple question ring and rod
All expansion and collapse of a-tree
boundary IoU 的计算方式
Interview questions for famous enterprises: Coins represent a given value
[groovy] mop meta object protocol and meta programming (execute groovy methods through metamethod invoke)
thinkphp5.1跨域问题解决
Technology cloud report won the special contribution award for the 10th anniversary of 2013-2022 of the "cloud Ding Award" of the global cloud computing conference
Web3为互联网带来了哪些改变?
344. Reverse String. Sol
Metaverse ape received $3.5 million in seed round financing from negentropy capital
Metaverse Ape上线倒计时,推荐活动火爆进行
QT creator 7-cmake update
点到直线的距离直线的交点及夹角
[Chongqing Guangdong education] National Open University autumn 2018 0088-21t Insurance Introduction reference questions
1.3 years of work experience, double non naked resignation agency face-to-face experience [already employed]
Serializability of concurrent scheduling