代码示例:
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");
}
}
}
效果图: 如果需要动态的增删面板内容,可以利用循环刷新,因为OnGUI函数是在不停刷新的。(可以自己打个Debug看下)
代码:
private void OnGUI()
{
if (GUILayout.Button("Add"))
{
count++;
isShowTextInfo = true;
}
if (isShowTextInfo)
{
for (int i = 0; i
关注
打赏