您当前的位置: 首页 >  unity
  • 4浏览

    0关注

    193博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

UnityEditor在编辑器中制作弹窗

我寄人间雪满头丶 发布时间:2020-03-09 14:25:39 ,浏览量:4

代码示例:

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             
关注
打赏
1648518768
查看更多评论
0.1918s