Version: 2022.3
public void Close ();

描述

关闭编辑器窗口。

执行此操作将销毁编辑器窗口。

\ 显示 Close() 的简单示例

using UnityEditor;
using UnityEngine;
using UnityEngine.UIElements;

public class CloseWindow : EditorWindow { [MenuItem("Window/UI Toolkit/CloseWindow")] public static void ShowExample() { CloseWindow wnd = GetWindow<CloseWindow>(); wnd.titleContent = new GUIContent("CloseWindow"); }

public void CreateGUI() { // Each editor window contains a root VisualElement object VisualElement root = rootVisualElement;

// Create button Button closebutton = new Button(); closebutton.text = "Close!";

// Set up event handler closebutton.RegisterCallback<ClickEvent>((ClickEvent evt) => { this.Close(); });

root.Add(closebutton);

} }