public void ShowPopup ();

描述

使用弹出式框架显示编辑器窗口。

这意味着,窗口没有框架且不可拖动。该方法用于在现有窗口中显示类似弹出菜单的内容。



使用此方法打开窗口不会赋予其弹出窗口的功能,仅样式相同而已。要想获得完整的弹出窗口功能(例如,在窗口失去焦点时自动关闭),请使用 PopupWindow

using UnityEngine;
using UnityEditor;

public class ShowPopupExample : EditorWindow { [MenuItem("Example/ShowPopup Example")] static void Init() { ShowPopupExample window = ScriptableObject.CreateInstance<ShowPopupExample>(); window.position = new Rect(Screen.width / 2, Screen.height / 2, 250, 150); window.ShowPopup(); }

void OnGUI() { EditorGUILayout.LabelField("This is an example of EditorWindow.ShowPopup", EditorStyles.wordWrappedLabel); GUILayout.Space(70); if (GUILayout.Button("Agree!")) this.Close(); } }