Custom Context Menu Attribute:可用于任何屬性,并將自定義選項添加到屬性的上下文菜單。當您要將自定義操作添加到屬性的上下文菜單時,請使用此選項。
using Sirenix.OdinInspector;
using UnityEngine;
public class CustomContextMenuAttributeExample : MonoBehaviour
{
[InfoBox("右鍵屬性可在菜單中出發指定的函數.")]
[CustomContextMenu("Say Hello/菜鳥海瀾", "SayHelloFunction")]
public int MyProperty;
private void SayHelloFunction()
{
Debug.Log("Hello 菜鳥海瀾");
}
}