Odin Inspector 系列教程 --- Custom Context Menu Attribute

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 菜鳥海瀾");
    }
}

更多教程內容詳見:革命性Unity 編輯器擴展工具 --- Odin Inspector 系列教程

?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容