Version: 2022.2

SceneView

class in UnityEditor

/

继承自:EditorWindow


实现接口:IHasCustomMenu, ISupportsOverlays

切换到手册

描述

使用此类可管理 SceneView 设置、更改 SceneView 摄像机属性、订阅事件、调用 SceneView 方法以及渲染打开的场景。

静态变量

currentDrawingSceneView所绘制的 SceneView。
lastActiveSceneView最近获得焦点的 SceneView。
lastActiveSceneViewChangedRegister to this callback to get notified when the active Scene View changes.
sceneViews所有打开的 Scene 视图窗口的列表。
selectedOutlineColor获取所选轮廓的 Color。

变量

audioPlay启用或禁用 Scene 视图音频效果。
camera渲染此 SceneView 的 Camera。
cameraDistance从 camera 到 pivot 的距离。
cameraModeScene 视图 camera 的当前 DrawCameraMode。
cameraSettings使用 CameraSettings 可为 SceneView 摄像机设置属性。
cameraViewportThe position and size of the area that the camera renders.
drawGizmos设置 Scene 视图中所有辅助图标的可见性。
in2DMode SceneView 是否处于 2D 模式。
isRotationLocked是否可以旋转 Scene 视图 camera。
isUsingSceneFilteringWhether this SceneView is using scene filtering.
lastSceneViewRotation当 Scene 视图处于 2D 模式时,此属性包含上一个 camera 旋转。
orthographicScene 视图摄像机是否设置为正交模式。
pivotThe central point that the camera orbits within the Scene view.
rotation camera 到 SceneView 的 pivot 的方向。
sceneLighting在 Scene 视图中启用还是禁用光照。
sceneViewState使用 SceneViewState 可为 Scene 视图设置调试选项。
showGrid获取或设置是否为 SceneView 的实例启用网格。
size沿对角线测量的 Scene 视图大小。
validateTrueMetals对于平均镜面反射颜色高于 0.45 的材质,反照率是否为黑色。

公共函数

AlignViewToObject移动 Scene 视图以框定变换。
AlignWithView将当前选择内容与 Scene 视图 camera 的位置和旋转对齐。
Frame框定 Scene 视图中的给定边界。
FrameSelected在 Scene 视图中框定对象选择。
IsCameraDrawModeEnabled如果在当前渲染设置(包括自定义验证器)中启用了模式,则返回 true。
IsCameraDrawModeSupportedChecks if the current rendering configuration supports the CameraMode. The check includes custom validators.
LookAt移动 Scene 视图以在目标上聚焦。
LookAtDirect LookAt,不对场景移动进行动画处理。
MoveToView将所有所选对象变换到场景 pivot。
ResetCameraSettings将 SceneView 摄像机的 CameraSettings 重置为默认值。
SetSceneViewShaderReplace设置替换着色器以用于渲染此 Scene 视图。

受保护的函数

SupportsStageHandling重载此方法来控制从一个阶段切换到另一个阶段时是否应更改 Scene 视图。

静态函数

AddCameraMode将自定义摄像机模式添加到 Scene 视图摄像机模式列表中。
AddOverlayToActiveViewAdd an Overlay to be displayed in the last focused Scene View. Overlays added to this static list will be automatically moved to the last active Scene View, and are displayed until removed.
ClearUserDefinedCameraModes删除所有用户定义的摄像机模式。
FrameLastActiveSceneView在最后一个活动 Scene 视图中框定当前所选对象。
GetAllSceneCameras从所有打开的 Scene 视图获取所有 camera 组件的数组。
GetBuiltinCameraMode获取与指定 DrawCameraMode 匹配的内置 CameraMode。
RemoveOverlayFromActiveViewRemove an Overlay from displaying in the last focused Scene View.
RepaintAll重绘每个打开的 SceneView。

Events

beforeSceneGui调用 OnGUI 方法时发出的事件。
duringSceneGui订阅此事件以在 Scene 视图每次调用 OnGUI 方法时接收回调。
gridVisibilityChanged在网格可见性更改时调用。
onCameraModeChanged所选 cameraMode 更改时调用的事件。

继承的成员

静态变量

focusedWindow当前已获得键盘焦点的 EditorWindow。(只读)
mouseOverWindow当前在鼠标光标下的 EditorWindow。(只读)

变量

autoRepaintOnSceneChange窗口是否会在场景每次发生变化时自动重绘?
dataModeControllerAn instance of IDataModeController to handle DataMode functionalities for the current window.
dockedReturns true if EditorWindow is docked.
hasFocusReturns true if EditorWindow is focused.
hasUnsavedChangesThis property specifies whether the Editor prompts the user to save or discard unsaved changes before the window closes.
maximized此窗口是否已最大化?
maxSizeThe maximum size of this window when it is floating or modal. The maximum size is not used when the window is docked.
minSizeThe minimum size of this window when it is floating or modal. The minimum size is not used when the window is docked.
overlayCanvasThe OverlayCanvas for this window.
position窗口在屏幕空间中的理想位置。
rootVisualElement获取窗口层级视图的根视觉元素。
saveChangesMessageThe message that displays to the user if they are prompted to save
titleContent用于绘制 EditorWindow 标题的 GUIContent。
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 事件。
hideFlags该对象应该隐藏、随场景一起保存还是由用户修改?
name对象的名称。

公共函数

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显示模态编辑器窗口。
ShowModalUtilityShows the EditorWindow as a floating modal window.
ShowNotification显示通知消息。
ShowPopup使用弹出式框架显示编辑器窗口。
ShowUtility将 EditorWindow 显示为浮动实用程序窗口。
TryGetOverlayGet an Overlay with matching ID from an EditorWindow canvas.
GetInstanceIDGets the instance ID of the object.
ToString返回对象的名称。

受保护的函数

OnBackingScaleFactorChangedCalled when the UI scaling for this EditorWindow is changed.

静态函数

CreateWindow创建类型为 T 的 EditorWindow。
FocusWindowIfItsOpen聚焦发现的第一个指定类型的 EditorWindow(如果已打开)。
GetWindowReturns the first EditorWindow of type windowType which is currently on the screen.
GetWindowWithRect返回当前屏幕上第一个 t 类型的 EditorWindow。
HasOpenInstances检查编辑器窗口是否已打开。
Destroy移除 GameObject、组件或资源。
DestroyImmediate立即销毁对象 /obj/。强烈建议您改用 Destroy。
DontDestroyOnLoad在加载新的 Scene 时,请勿销毁 Object。
FindAnyObjectByTypeRetrieves any active loaded object of Type type.
FindFirstObjectByTypeRetrieves the first active loaded object of Type type.
FindObjectOfType返回第一个类型为 type 的已加载的激活对象。
FindObjectsByTypeRetrieves a list of all loaded objects of Type type.
FindObjectsOfTypeGets a list of all loaded objects of Type type.
Instantiate克隆 original 对象并返回克隆对象。
CreateInstance创建脚本化对象的实例。

运算符

bool该对象是否存在?
operator !=比较两个对象是否引用不同的对象。
operator ==比较两个对象引用,判断它们是否引用同一个对象。

消息

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.
OnBecameInvisibleCalled after the window is removed from a container view, or is no longer visible within a tabbed collection of EditorWindow.
OnBecameVisibleCalled after the window is added to a container view.
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在所有可见窗口上每秒调用多次。
Awake当 ScriptableObject 脚本启动时调用此函数。
OnDestroy当脚本化对象将销毁时调用此函数。
OnDisable当脚本化对象超出范围时调用此函数。
OnEnable当对象加载时调用此函数。
OnValidateEditor-only function that Unity calls when the script is loaded or a value changes in the Inspector.
Reset重置为默认值。