Namespace: | Sirenix.OdinInspector |
Assembly: | Sirenix.OdinInspector.Attributes |
[DontApplyToListElements]
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Parameter | AttributeTargets.Delegate | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter | AttributeTargets.All, AllowMultiple = true, Inherited = true)]
[Conditional("UNITY_EDITOR")]
public sealed class CustomContextMenuAttribute : Attribute, _Attribute
CustomContextMenu is used on any property, and adds a custom options to the context menu for the property.
Use this for when you want to add custom actions to the context menu of a property.
CustomContextMenu currently does not support static functions.
The following example shows how CustomContextMenu is used to add a custom option to a property.
public class MyComponent : MonoBehaviour
{
[CustomContextMenu("My custom option", "MyAction")]
public Vector3 MyVector;
private void MyAction()
{
MyVector = Random.onUnitSphere;
}
}
public CustomContextMenuAttribute(string menuItem, string action)
System.String | menuItem | The name of the menu item. |
System.String | action | A resolved string defining the action to take when the context menu is clicked. |
public string Action
public string MenuItem