Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


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

[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

functionThe name of the function that should be called.
nameThe 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.

Inheritance

Inherited Members