diff --git a/Source/Editor/Options/InputOptions.cs b/Source/Editor/Options/InputOptions.cs
index 8f690454e..b6b716fb5 100644
--- a/Source/Editor/Options/InputOptions.cs
+++ b/Source/Editor/Options/InputOptions.cs
@@ -151,6 +151,30 @@ namespace FlaxEditor.Options
[DefaultValue(typeof(InputBinding), "Q")]
[EditorDisplay("Viewport"), EditorOrder(1550)]
public InputBinding Down = new InputBinding(KeyboardKeys.Q);
+
+ [DefaultValue(typeof(InputBinding), "Numpad0")]
+ [EditorDisplay("Viewport"), EditorOrder(1600)]
+ public InputBinding ViewpointFront = new InputBinding(KeyboardKeys.Numpad0);
+
+ [DefaultValue(typeof(InputBinding), "Numpad5")]
+ [EditorDisplay("Viewport"), EditorOrder(1610)]
+ public InputBinding ViewpointBack = new InputBinding(KeyboardKeys.Numpad5);
+
+ [DefaultValue(typeof(InputBinding), "Numpad4")]
+ [EditorDisplay("Viewport"), EditorOrder(1620)]
+ public InputBinding ViewpointLeft = new InputBinding(KeyboardKeys.Numpad4);
+
+ [DefaultValue(typeof(InputBinding), "Numpad6")]
+ [EditorDisplay("Viewport"), EditorOrder(1630)]
+ public InputBinding ViewpointRight = new InputBinding(KeyboardKeys.Numpad6);
+
+ [DefaultValue(typeof(InputBinding), "Numpad8")]
+ [EditorDisplay("Viewport"), EditorOrder(1640)]
+ public InputBinding ViewpointTop = new InputBinding(KeyboardKeys.Numpad8);
+
+ [DefaultValue(typeof(InputBinding), "Numpad2")]
+ [EditorDisplay("Viewport"), EditorOrder(1650)]
+ public InputBinding ViewpointBottom = new InputBinding(KeyboardKeys.Numpad2);
#endregion
diff --git a/Source/Editor/Viewport/EditorViewport.cs b/Source/Editor/Viewport/EditorViewport.cs
index 9c4dcc253..9a9ae9d7d 100644
--- a/Source/Editor/Viewport/EditorViewport.cs
+++ b/Source/Editor/Viewport/EditorViewport.cs
@@ -1,6 +1,7 @@
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
using System;
+using System.Linq;
using FlaxEditor.GUI.ContextMenu;
using FlaxEditor.GUI.Input;
using FlaxEditor.Options;
@@ -649,6 +650,13 @@ namespace FlaxEditor.Viewport
}
}
+ InputActions.Add(options => options.ViewpointTop, () => OrientViewport(Quaternion.Euler(EditorViewportCameraViewpointValues.First(vp => vp.Name == "Top").Orientation)));
+ InputActions.Add(options => options.ViewpointBottom, () => OrientViewport(Quaternion.Euler(EditorViewportCameraViewpointValues.First(vp => vp.Name == "Bottom").Orientation)));
+ InputActions.Add(options => options.ViewpointFront, () => OrientViewport(Quaternion.Euler(EditorViewportCameraViewpointValues.First(vp => vp.Name == "Front").Orientation)));
+ InputActions.Add(options => options.ViewpointBack, () => OrientViewport(Quaternion.Euler(EditorViewportCameraViewpointValues.First(vp => vp.Name == "Back").Orientation)));
+ InputActions.Add(options => options.ViewpointRight, () => OrientViewport(Quaternion.Euler(EditorViewportCameraViewpointValues.First(vp => vp.Name == "Right").Orientation)));
+ InputActions.Add(options => options.ViewpointLeft, () => OrientViewport(Quaternion.Euler(EditorViewportCameraViewpointValues.First(vp => vp.Name == "Left").Orientation)));
+
// Link for task event
task.Begin += OnRenderBegin;
}
@@ -658,6 +666,16 @@ namespace FlaxEditor.Viewport
///
protected virtual bool IsControllingMouse => false;
+ ///
+ /// Orients the viewport.
+ ///
+ /// The orientation.
+ protected void OrientViewport(Quaternion orientation)
+ {
+ var quat = orientation;
+ OrientViewport(ref quat);
+ }
+
///
/// Orients the viewport.
///
diff --git a/Source/Editor/Viewport/MainEditorGizmoViewport.cs b/Source/Editor/Viewport/MainEditorGizmoViewport.cs
index 8bc6b4c02..6202a8d6e 100644
--- a/Source/Editor/Viewport/MainEditorGizmoViewport.cs
+++ b/Source/Editor/Viewport/MainEditorGizmoViewport.cs
@@ -656,11 +656,20 @@ namespace FlaxEditor.Viewport
/// Focuses the viewport on the current selection of the gizmo.
///
public void FocusSelection()
+ {
+ var orientation = ViewOrientation;
+ FocusSelection(ref orientation);
+ }
+
+ ///
+ /// Focuses the viewport on the current selection of the gizmo.
+ ///
+ /// The target view orientation.
+ public void FocusSelection(ref Quaternion orientation)
{
if (TransformGizmo.SelectedParents.Count == 0)
return;
- var orientation = ViewOrientation;
var gizmoBounds = Gizmos.Active.FocusBounds;
if (gizmoBounds != BoundingSphere.Empty)
((FPSCamera)ViewportCamera).ShowSphere(ref gizmoBounds, ref orientation);
@@ -725,9 +734,10 @@ namespace FlaxEditor.Viewport
///
protected override void OrientViewport(ref Quaternion orientation)
{
- FocusSelection();
-
- base.OrientViewport(ref orientation);
+ if (TransformGizmo.SelectedParents.Count != 0)
+ FocusSelection(ref orientation);
+ else
+ base.OrientViewport(ref orientation);
}
///
diff --git a/Source/Editor/Viewport/PrefabWindowViewport.cs b/Source/Editor/Viewport/PrefabWindowViewport.cs
index 1c337cc25..946cf3620 100644
--- a/Source/Editor/Viewport/PrefabWindowViewport.cs
+++ b/Source/Editor/Viewport/PrefabWindowViewport.cs
@@ -787,11 +787,20 @@ namespace FlaxEditor.Viewport
/// Focuses the viewport on the current selection of the gizmo.
///
public void FocusSelection()
+ {
+ var orientation = ViewOrientation;
+ FocusSelection(ref orientation);
+ }
+
+ ///
+ /// Focuses the viewport on the current selection of the gizmo.
+ ///
+ /// The target view orientation.
+ public void FocusSelection(ref Quaternion orientation)
{
if (TransformGizmo.SelectedParents.Count == 0)
return;
- var orientation = ViewOrientation;
var gizmoBounds = Gizmos.Active.FocusBounds;
if (gizmoBounds != BoundingSphere.Empty)
((FPSCamera)ViewportCamera).ShowSphere(ref gizmoBounds, ref orientation);
@@ -802,9 +811,10 @@ namespace FlaxEditor.Viewport
///
protected override void OrientViewport(ref Quaternion orientation)
{
- FocusSelection();
-
- base.OrientViewport(ref orientation);
+ if (TransformGizmo.SelectedParents.Count != 0)
+ FocusSelection(ref orientation);
+ else
+ base.OrientViewport(ref orientation);
}
///