Class EditorViewport
Editor viewports base class.
Inheritance
Implements
Namespace: FlaxEditor.Viewport
Assembly: FlaxEngine.CSharp.dll
Syntax
public class EditorViewport : RenderOutputControl, IComparable, IDrawableConstructors
EditorViewport(SceneRenderTask, ViewportCamera, Boolean)
Initializes a new instance of the EditorViewport class.
Declaration
public EditorViewport(SceneRenderTask task, ViewportCamera camera, bool useWidgets)Parameters
| SceneRenderTask
        task The task. | 
| FlaxEditor.Viewport.Cameras.ViewportCamera
        camera The camera controller. | 
| System.Boolean
        useWidgets Enable/disable viewport widgets. | 
Fields
_cameraButton
The camera settings widget button.
Declaration
protected ViewportWidgetButton _cameraButtonField Value
| FlaxEditor.Viewport.Widgets.ViewportWidgetButton 
 | 
_cameraWidget
The camera settings widget.
Declaration
protected ViewportWidgetsContainer _cameraWidgetField Value
| FlaxEditor.Viewport.Widgets.ViewportWidgetsContainer 
 | 
_input
The input data (from the current frame).
Declaration
protected EditorViewport.Input _inputField Value
| EditorViewport.Input 
 | 
_mouseDelta
_orthographicModeButton
The orthographic mode widget button.
Declaration
protected ViewportWidgetButton _orthographicModeButtonField Value
| FlaxEditor.Viewport.Widgets.ViewportWidgetButton 
 | 
_prevInput
The previous input (from the previous update).
Declaration
protected EditorViewport.Input _prevInputField Value
| EditorViewport.Input 
 | 
_viewMousePos
FpsCameraFilteringFrames
The FPS camera filtering frames count (how much frames we want to keep in the buffer to calculate the avg. delta currently hardcoded).
Declaration
public const int FpsCameraFilteringFrames = 3Field Value
| System.Int32 
 | 
InputActions
The input actions collection to processed during user input.
Declaration
public InputActionsContainer InputActionsField Value
| InputActionsContainer 
 | 
MouseSpeed
Speed of the mouse.
Declaration
public float MouseSpeedField Value
| System.Single 
 | 
MouseWheelZoomSpeedFactor
Speed of the mouse wheel zooming.
Declaration
public float MouseWheelZoomSpeedFactorField Value
| System.Single 
 | 
ViewWidgetButtonMenu
The 'View' widget button context menu.
Declaration
public ContextMenu ViewWidgetButtonMenuField Value
| FlaxEditor.GUI.ContextMenu.ContextMenu 
 | 
ViewWidgetShowMenu
The 'View' widget 'Show' category context menu.
Declaration
public ContextMenu ViewWidgetShowMenuField Value
| FlaxEditor.GUI.ContextMenu.ContextMenu 
 | 
Properties
EulerAngles
Gets or sets the euler angles (pitch, yaw, roll).
Declaration
public Float3 EulerAngles { get; set; }Property Value
| Float3 
 | 
FarPlane
Gets or sets the camera far clipping plane.
Declaration
public float FarPlane { get; set; }Property Value
| System.Single 
 | 
FieldOfView
Gets or sets the camera field of view (in degrees).
Declaration
public float FieldOfView { get; set; }Property Value
| System.Single 
 | 
HasLoadedAssets
Gets a value indicating whether this viewport has loaded dependant assets.
Declaration
public virtual bool HasLoadedAssets { get; }Property Value
| System.Boolean 
 | 
InvertPanning
Gets or sets if the panning direction is inverted.
Declaration
public bool InvertPanning { get; set; }Property Value
| System.Boolean 
 | 
IsControllingMouse
Gets a value indicating whether this viewport is using mouse currently (eg. user moving objects).
Declaration
protected virtual bool IsControllingMouse { get; }Property Value
| System.Boolean 
 | 
MaxMovementSpeed
Gets or sets the maximum camera movement speed.
Declaration
public float MaxMovementSpeed { get; set; }Property Value
| System.Single 
 | 
MinMovementSpeed
Gets or sets the minimum camera movement speed.
Declaration
public float MinMovementSpeed { get; set; }Property Value
| System.Single 
 | 
MousePositionDelta
Gets the mouse movement position delta (user press and move).
Declaration
public Float2 MousePositionDelta { get; }Property Value
| Float2 
 | 
MouseRay
MovementSpeed
Gets or sets the camera movement speed.
Declaration
public float MovementSpeed { get; set; }Property Value
| System.Single 
 | 
NearPlane
Gets or sets the camera near clipping plane.
Declaration
public float NearPlane { get; set; }Property Value
| System.Single 
 | 
OrthographicScale
Gets or sets the camera orthographic size scale (if camera uses orthographic mode).
Declaration
public float OrthographicScale { get; set; }Property Value
| System.Single 
 | 
PanningSpeed
Gets or sets the camera panning speed.
Declaration
public float PanningSpeed { get; set; }Property Value
| System.Single 
 | 
Pitch
Gets or sets the pitch angle (in degrees).
Declaration
public float Pitch { get; set; }Property Value
| System.Single 
 | 
RelativePanning
Gets or sets if the panning speed should be relative to the camera target.
Declaration
public bool RelativePanning { get; set; }Property Value
| System.Boolean 
 | 
ShowFpsCounter
Gets or sets a value indicating whether show or hide FPS counter.
Declaration
public bool ShowFpsCounter { get; set; }Property Value
| System.Boolean 
 | 
UseCameraEasing
Gets or sets the camera easing mode.
Declaration
public bool UseCameraEasing { get; set; }Property Value
| System.Boolean 
 | 
UseOrthographicProjection
Gets or sets the camera orthographic mode (otherwise uses perspective projection).
Declaration
public bool UseOrthographicProjection { get; set; }Property Value
| System.Boolean 
 | 
ViewDirection
Gets or sets the view direction vector.
Declaration
public Float3 ViewDirection { get; set; }Property Value
| Float3 
 | 
ViewFrustum
Gets the bounding frustum of the current viewport camera.
Declaration
public BoundingFrustum ViewFrustum { get; }Property Value
| BoundingFrustum 
 | 
ViewOrientation
Gets or sets the view orientation.
Declaration
public Quaternion ViewOrientation { get; set; }Property Value
| Quaternion 
 | 
ViewportCamera
Gets or sets the viewport camera controller.
Declaration
public ViewportCamera ViewportCamera { get; set; }Property Value
| FlaxEditor.Viewport.Cameras.ViewportCamera 
 | 
ViewPosition
Gets or sets the view position.
Declaration
public Vector3 ViewPosition { get; set; }Property Value
| Vector3 
 | 
ViewRay
Gets or sets the view ray (position and direction).
Declaration
public Ray ViewRay { get; set; }Property Value
| Ray 
 | 
ViewTransform
Gets the view transform.
Declaration
public Transform ViewTransform { get; set; }Property Value
| Transform 
 | 
Yaw
Gets or sets the yaw angle (in degrees).
Declaration
public float Yaw { get; set; }Property Value
| System.Single 
 | 
YawPitch
Gets or sets the absolute mouse position (normalized, not in pixels). Yaw is X, Pitch is Y.
Declaration
public Float2 YawPitch { get; set; }Property Value
| Float2 
 | 
Methods
AdjustCameraMoveSpeed(Int32)
Increases or decreases the camera movement speed.
Declaration
protected void AdjustCameraMoveSpeed(int step)Parameters
| System.Int32
        step The stepping direction for speed adjustment. | 
ConvertMouseToRay(ref Float2)
Converts the mouse position to the ray (in world space of the viewport).
Declaration
public Ray ConvertMouseToRay(ref Float2 mousePosition)Parameters
| Float2
        mousePosition The mouse position (in UI space of the viewport [0; Size]). | 
Returns
| Ray The result ray. | 
CopyViewData(ref RenderView)
Copies the render view data to RenderView structure.
Declaration
public void CopyViewData(ref RenderView view)Parameters
| RenderView
        view The view. | 
CreateProjectionMatrix(out Matrix)
Creates the projection matrix.
Declaration
protected virtual void CreateProjectionMatrix(out Matrix result)Parameters
| Matrix
        result The result. | 
CreateViewMatrix(Float3, out Matrix)
Creates the view matrix.
Declaration
protected virtual void CreateViewMatrix(Float3 position, out Matrix result)Parameters
| Float3
        position The view position. | 
| Matrix
        result The result. | 
Draw()
Declaration
public override void Draw()Overrides
GetInput(out EditorViewport.Input)
Gets the input state data.
Declaration
public void GetInput(out EditorViewport.Input input)Parameters
| EditorViewport.Input
        input The input. | 
GetPrevInput(out EditorViewport.Input)
Gets the input state data (from the previous update).
Declaration
public void GetPrevInput(out EditorViewport.Input input)Parameters
| EditorViewport.Input
        input The input. | 
OnChildResized(Control)
Called when child control gets resized.
Declaration
public override void OnChildResized(Control control)Parameters
| Control
        control The resized control. | 
Overrides
OnControlMouseBegin(Window)
Called when mouse control begins.
Declaration
protected virtual void OnControlMouseBegin(Window win)Parameters
| Window
        win The parent window. | 
OnControlMouseEnd(Window)
Called when mouse control ends.
Declaration
protected virtual void OnControlMouseEnd(Window win)Parameters
| Window
        win The parent window. | 
OnDestroy()
Declaration
public override void OnDestroy()Overrides
OnKeyDown(KeyboardKeys)
When key goes down
Declaration
public override bool OnKeyDown(KeyboardKeys key)Parameters
| KeyboardKeys
        key Key value | 
Returns
| System.Boolean True if event has been handled, otherwise false | 
Overrides
OnLeftMouseButtonDown()
Called when left mouse button goes down (on press).
Declaration
protected virtual void OnLeftMouseButtonDown()OnLeftMouseButtonUp()
Called when left mouse button goes up (on release).
Declaration
protected virtual void OnLeftMouseButtonUp()OnLostFocus()
When control losts input focus
Declaration
public override void OnLostFocus()Overrides
OnMiddleMouseButtonDown()
Called when middle mouse button goes down (on press).
Declaration
protected virtual void OnMiddleMouseButtonDown()OnMiddleMouseButtonUp()
Called when middle mouse button goes up (on release).
Declaration
protected virtual void OnMiddleMouseButtonUp()OnMouseDown(Float2, MouseButton)
When mouse goes down over control's area
Declaration
public override bool OnMouseDown(Float2 location, MouseButton button)Parameters
| Float2
        location Mouse location in Control Space | 
| MouseButton
        button Mouse buttons state (flags) | 
Returns
| System.Boolean True if event has been handled, otherwise false | 
Overrides
OnMouseWheel(Float2, Single)
When mouse wheel moves
Declaration
public override bool OnMouseWheel(Float2 location, float delta)Parameters
| Float2
        location Mouse location in Control Space | 
| System.Single
        delta Mouse wheel move delta. A positive value indicates that the wheel was rotated forward, away from the user; a negative value indicates that the wheel was rotated backward, toward the user. Normalized to [-1;1] range. | 
Returns
| System.Boolean True if event has been handled | 
Overrides
OnRightMouseButtonDown()
Called when right mouse button goes down (on press).
Declaration
protected virtual void OnRightMouseButtonDown()OnRightMouseButtonUp()
Called when right mouse button goes up (on release).
Declaration
protected virtual void OnRightMouseButtonUp()OrientViewport(Quaternion)
Orients the viewport.
Declaration
protected void OrientViewport(Quaternion orientation)Parameters
| Quaternion
        orientation The orientation. | 
OrientViewport(ref Quaternion)
Orients the viewport.
Declaration
protected virtual void OrientViewport(ref Quaternion orientation)Parameters
| Quaternion
        orientation The orientation. | 
PerformLayoutBeforeChildren()
Perform layout for that container control before performing it for child controls.
Declaration
protected override void PerformLayoutBeforeChildren()Overrides
ProjectPoint(Vector3, out Float2)
Projects the point from 3D world-space to viewport coordinates.
Declaration
public void ProjectPoint(Vector3 worldSpaceLocation, out Float2 viewportSpaceLocation)Parameters
| Vector3
        worldSpaceLocation The input world-space location (XYZ in world). | 
| Float2
        viewportSpaceLocation The output viewport window coordinates (XY in screen pixels). | 
TakeScreenshot(String)
Takes the screenshot of the current viewport.
Declaration
public void TakeScreenshot(string path = null)Parameters
| System.String
        path The output file path. Set null to use default value. | 
Update(Single)
Perform control update and all its children
Declaration
public override void Update(float deltaTime)Parameters
| System.Single
        deltaTime Delta time in seconds | 
Overrides
UpdateView(Single, ref Vector3, ref Float2, out Boolean)
Updates the view.
Declaration
protected virtual void UpdateView(float dt, ref Vector3 moveDelta, ref Float2 mouseDelta, out bool centerMouse)Parameters
| System.Single
        dt The delta time (in seconds). | 
| Vector3
        moveDelta The move delta (scaled). | 
| Float2
        mouseDelta The mouse delta (scaled). | 
| System.Boolean
        centerMouse True if center mouse after the update. |