Unity编辑器开发——EditorWindow

官方文档:EditorWindow - Unity 脚本 API

EditorWindow  继承自  ScriptableObject

一、变量

1.静态变量

变量名官方解释使用场景
focusWindow当前已获得键盘焦点的 EditorWindow。(只读)
mouseOverWindow当前在鼠标光标下的 EditorWindow。(只读)

2.变量

变量名官方解释使用场景
titleContent用于绘制 EditorWindow 标题的 GUIContent。
position窗口在屏幕空间中的理想位置。
maxSize窗口最大值
minSize窗口最小值
maximized此窗口是否已最大化?
rootVisualElement获取窗口层级视图的根视觉元素。
hasFocus窗口是否被聚焦
autoRepaintOnSceneChange窗口是否会在场景每次发生变化时自动重绘?
dockedReturns true if EditorWindow is docked.
hasUnsavedChangesThis property specifies whether the Editor prompts the user to save or discard unsaved changes before the window closes.
saveChangesMessageThe message that displays to the user if they are prompted to save
wantsLessLayoutEventsSpecifies whether a layout pass is performed before all user events (for example, EventType.MouseDown or [[EventType, KeyDown]]), or is only performed before repaint events.
wantsMouseEnterLeaveWindow检查是否已在此编辑器窗口的 GUI 中收到 MouseEnterWindow 和 MouseLeaveWindow 事件。
wantsMouseMove检查是否已在此编辑器窗口的 GUI 中收到 MouseMove 事件。

二、方法

1.受保护的方法

变量名官方解释使用场景
OnBackingScaleFactorChangedCalled when the UI scaling for this EditorWindow is changed.

2.静态方法

变量名官方解释使用场景
CreateWindow创建类型为 T 的 EditorWindow。
FocusWindowIfItsOpen聚焦发现的第一个指定类型的 EditorWindow(如果已打开)。
GetWindow返回当前屏幕上第一个 t 类型的 EditorWindow。
GetWindowWithRect返回当前屏幕上第一个 t 类型的 EditorWindow。
HasOpenInstances检查编辑器窗口是否已打开。

3.方法

BeginWindows标记所有弹出窗口的开始区域。
Close关闭编辑器窗口。
DiscardChangesDiscards unsaved changes to the contents of the window.
EndWindows关闭由 EditorWindow.BeginWindows 开始的窗口组。
Focus将键盘焦点移动到另一个 EditorWindow。
GetExtraPaneTypes获取与窗口关联的额外窗格。
RemoveNotification停止显示通知消息。
Repaint重绘窗口。
SaveChangesPerforms a save action on the contents of the window.
SendEvent将事件发送到窗口。
Show显示 EditorWindow 窗口。
ShowAsDropDown显示包含下拉菜单和样式的窗口。
ShowAuxWindow在辅助窗口中显示编辑器窗口。
ShowModal显示模态编辑器窗口。
ShowModalUtility将 EditorWindow 显示为浮动模态窗口。
ShowNotification显示通知消息。
ShowPopup使用弹出式框架显示编辑器窗口。
ShowUtility将 EditorWindow 显示为浮动实用程序窗口。
TryGetOverlayGet an Overlay with matching ID from an EditorWindow canvas.

三、消息(生命周期)

Awake在新窗口打开时调用。
CreateGUICreateGUI is called when the EditorWindow's rootVisualElement is ready to be populated.
hasUnsavedChangesThis property specifies whether the Editor prompts the user to save or discard unsaved changes before the window closes.
OnDestroy调用 OnDestroy 以关闭 EditorWindow 窗口。
OnFocus在窗口获得键盘焦点时调用。
OnGUI在此处实现您自己的 Editor GUI。
OnHierarchyChange处理程序,用于在层级视图中的对象或对象组发生更改时发送的消息。
OnInspectorUpdateOnInspectorUpdate 以每秒 10 帧的速度调用,以便检视面板有机会进行更新。
OnLostFocus在窗口失去键盘焦点时调用。
OnProjectChange处理程序,用于在项目状态发生更改时发送的消息。
OnSelectionChange每当选择发生更改时调用。
saveChangesMessageThe message that displays to the user if they are prompted to save
Update在所有可见窗口上每秒调用多次。
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值