一、AddComponentMenu
[AddComponentMenu("xxx/yyy")]
public class MyComponent:MonoBehaviour{
}
二、RequireComponent
public class MyBaseComponent:MonoBehaviour{
}
[RequireComponent(typeof(MyBaseComponent))]
public class MyComponent:MonoBehaviour{
}
三、ContextMenu、ContextMenuItem
public class MyComponent:MonoBehaviour{
[ContextMenuItem("名字详细信息","MyNameMethod")]
public string name;
private void MyNameMethod(){
Debug.Log("打印名字:" + name);
}
[ContextMenu("菜单选项执行方法")]
private void MyContextMenuMethod(){
}
}
四、HelpURL
[HelpURL("http://www.baidu.com")]
public class MyComponent:MonoBehaviour{
}
五、Header、ToolTip
public class MyComponent:MonoBehaviour{
[Header("设置年龄")]
public int age;
[ToolTip("这是名字")]
public string name;
}
六、Serializable、SerializeField、HideInInspector、NonSerialized
[Serializable]
public struct MyStruct
{
public string name;
public int age;
}
public class MyComponent:MonoBehaviour{
[Header("自定义结构体")]
public MyStruct myStruct;
[SerializeField]
private string name;
[HideInInspector]
public string country;
}
七、其他
Space
Range
Multiline
InitializeOnLoad
Comments | NOTHING
该文章已经关闭评论