当前位置:网站首页>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;
}
}
边栏推荐
- ESP32 hosted
- Granularity of blocking of concurrency control
- Performance monitoring of database tuning solutions
- Sub total of Pico development
- Server optimization of performance tuning methodology
- Postman core function analysis - parameterization and test report
- Unique occurrence times of leetcode simple questions
- Alternating merging strings of leetcode simple questions
- Search: Future Vision (moving sword)
- Leetcode simple question check whether all characters appear the same number of times
猜你喜欢

南京:全面启用商品房买卖电子合同

Nacos installation and service registration

Practice: fabric user certificate revocation operation process

Livelocks and deadlocks of concurrency control

How can easycvr cluster deployment solve the massive video access and concurrency requirements in the project?

Interview questions for famous enterprises: Coins represent a given value

EasyCVR集群部署如何解决项目中的海量视频接入与大并发需求?

U盘的文件无法删除文件怎么办?Win11无法删除U盘文件解决教程

MySQL服务莫名宕机的解决方案

Matlab draws a cute fat doll
随机推荐
记录几个常见问题(202207)
Performance testing of software testing
Promql demo service
Cobaltstrike builds an intranet tunnel
Performance monitoring of database tuning solutions
如何创建线程
The difference between MVVM and MVC
Text组件新增内容通过tag_config设置前景色、背景色
Hcip day 16
Oracle advanced query
Win11运行cmd提示“请求的操作需要提升”的解决方法
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
Sub total of Pico development
Metaverse ape received $3.5 million in seed round financing from negentropy capital
Learning of mall permission module
谷歌地图案例
When the industrial Internet era is truly mature, we will look at the emergence of a series of new industrial giants
Common interview questions of redis factory
Distance entre les points et les lignes
Oracle is sorted by creation time. If the creation time is empty, the record is placed last













