unity中Inspector屬性面板的擴展三

擴展自帶的主鍵屬性,比如說Main Camera

1.新建C#腳本,命名爲CameraEditor

using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;


[CustomEditor(typeof(Camera))]
public class CameraEditor : Editor {
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();
        GUILayout.Label("********以下是擴展選項********");
        if(GUILayout.Button("點擊處理"))
        {
            Debug.Log("檢測到點擊了");
        }
    }

}

需要擴展哪個主鍵只需要把主鍵的類型傳進去就可以了

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章