代碼示例:
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");
}
}
}
效果圖: