ContextMenuItemAttribute
Use this attribute to add a context menu to a field that calls a named method.
Read time 3 minutesLast updated 4 days ago
Definition
- Type: Class
- Namespace: UnityEngine
- Assembly: UnityEngine.CoreModule
- Inherits from: PropertyAttribute
[AttributeUsage(AttributeTargets.Field, Inherited = true, AllowMultiple = true)]public class ContextMenuItemAttribute : PropertyAttribute
Examples
using UnityEngine;public class Example : MonoBehaviour{ [ContextMenuItem("Reset", "ResetBiography")] [Multiline(8)] [SerializeField] string playerBiography = ""; void ResetBiography() { playerBiography = ""; }}
Fields
Value | Description |
|---|---|
| function | The name of the function that should be called. |
| name | The name of the context menu item. |
Constructors
Constructor | Description |
|---|---|
| ContextMenuItemAttribute(System.String,System.String) | Use this attribute to add a context menu to a field that calls a named method. |