UnityEditor在編輯器中製作彈窗

代碼示例:

using UnityEngine;
using UnityEditor;

public class GetItemsTool : EditorWindow
{
    int id;

    private void Awake()
    {
        //窗口彈出時候調用
        Debug.Log("My Window Start");
    }

    void Update()
    {
        //窗口彈出時候每幀調用
        Debug.Log("My Window Update");
    }

    [MenuItem("MyTools/GetItem")]
    static void Init()
    {
        GetWindow(typeof(GetItemsTool));
    }

    void OnGUI()
    {
        id = EditorGUILayout.IntField(id);
        if(GUILayout.Button("Get"))
        {
            Debug.Log("Test");
        }
    }
}

效果圖:
在這裏插入圖片描述

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