代码:

using UnityEngine;
using UnityEditor;

public class MyWidow : EditorWindow
{
    [MenuItem("Window/Show MyWindow")]
    static void ShowMyWindow()
    {
        MyWidow myWindow = EditorWindow.GetWindow<MyWidow>();//创建自定义窗口
        myWindow.Show();//显示创建的自定义窗口
    }
    private string name = "";
    void OnGUI()
    {
        GUILayout.Label("这是我的自定义窗口");
        name = GUILayout.TextField(name);
        if (GUILayout.Button("创建"))
        {
            GameObject go = new GameObject(name);
            Undo.RegisterCreatedObjectUndo(go, "create gameObject");//允许撤回
        }
    }
}

相关文章:

  • 2021-12-26
  • 2022-12-23
  • 2021-04-10
  • 2022-01-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-20
  • 2021-09-10
  • 2022-12-23
  • 2021-04-29
相关资源
相似解决方案