diff --git a/Source/Editor/Options/ViewportOptions.cs b/Source/Editor/Options/ViewportOptions.cs
index 6e1f8a9d6..5558ac89d 100644
--- a/Source/Editor/Options/ViewportOptions.cs
+++ b/Source/Editor/Options/ViewportOptions.cs
@@ -45,5 +45,12 @@ namespace FlaxEditor.Options
[DefaultValue(60.0f), Limit(35.0f, 160.0f, 0.1f)]
[EditorDisplay("Defaults", "Default Field Of View"), EditorOrder(140), Tooltip("The default field of view angle (in degrees) for the viewport camera.")]
public float DefaultFieldOfView { get; set; } = 60.0f;
+
+ ///
+ /// Gets or sets if the panning direction is inverted for the viewport camera.
+ ///
+ [DefaultValue(false)]
+ [EditorDisplay("Defaults"), EditorOrder(150), Tooltip( "Invert the panning direction for the viewport camera." )]
+ public bool DefaultInvertPanning { get; set; } = false;
}
}
diff --git a/Source/Editor/Viewport/Cameras/FPSCamera.cs b/Source/Editor/Viewport/Cameras/FPSCamera.cs
index 8ed219449..8a84390eb 100644
--- a/Source/Editor/Viewport/Cameras/FPSCamera.cs
+++ b/Source/Editor/Viewport/Cameras/FPSCamera.cs
@@ -188,8 +188,16 @@ namespace FlaxEditor.Viewport.Cameras
if (input.IsPanning)
{
var panningSpeed = 0.8f;
- position -= right * (mouseDelta.X * panningSpeed);
- position -= up * (mouseDelta.Y * panningSpeed);
+ if (_invertPanning)
+ {
+ position += up * (mouseDelta.Y * panningSpeed);
+ position += right * (mouseDelta.X * panningSpeed);
+ }
+ else
+ {
+ position -= right * (mouseDelta.X * panningSpeed);
+ position -= up * (mouseDelta.Y * panningSpeed);
+ }
}
// Move
diff --git a/Source/Editor/Viewport/Cameras/ViewportCamera.cs b/Source/Editor/Viewport/Cameras/ViewportCamera.cs
index a01000035..21993f55c 100644
--- a/Source/Editor/Viewport/Cameras/ViewportCamera.cs
+++ b/Source/Editor/Viewport/Cameras/ViewportCamera.cs
@@ -12,6 +12,7 @@ namespace FlaxEditor.Viewport.Cameras
public abstract class ViewportCamera : IViewportCamera
{
private EditorViewport _viewport;
+ protected bool _invertPanning;
///
/// Gets the parent viewport.
@@ -27,6 +28,14 @@ namespace FlaxEditor.Viewport.Cameras
///
public virtual bool UseMovementSpeed => true;
+ ///
+ /// Sets if the panning direction is inverted.
+ ///
+ public bool InvertPanning
+ {
+ set => _invertPanning = value;
+ }
+
///
/// Sets view orientation and position to match the arc ball camera style view for the given target object bounds.
///
diff --git a/Source/Editor/Viewport/EditorViewport.cs b/Source/Editor/Viewport/EditorViewport.cs
index 0b810e891..fc777d1a9 100644
--- a/Source/Editor/Viewport/EditorViewport.cs
+++ b/Source/Editor/Viewport/EditorViewport.cs
@@ -180,6 +180,7 @@ namespace FlaxEditor.Viewport
private float _orthoSize = 1.0f;
private bool _isOrtho = false;
private float _wheelMovementChangeDeltaSum = 0;
+ private bool _invertPanning;
///
/// Speed of the mouse.
@@ -403,6 +404,15 @@ namespace FlaxEditor.Viewport
set => _isOrtho = value;
}
+ ///
+ /// Gets or sets if the panning direction is inverted.
+ ///
+ public bool InvertPanning
+ {
+ get => _invertPanning;
+ set => _invertPanning = value;
+ }
+
///
/// The input actions collection to processed during user input.
///
@@ -434,6 +444,7 @@ namespace FlaxEditor.Viewport
_nearPlane = options.Viewport.DefaultNearPlane;
_farPlane = options.Viewport.DefaultFarPlane;
_fieldOfView = options.Viewport.DefaultFieldOfView;
+ _invertPanning = options.Viewport.DefaultInvertPanning;
Editor.Instance.Options.OptionsChanged += OnEditorOptionsChanged;
OnEditorOptionsChanged(options);
@@ -515,7 +526,7 @@ namespace FlaxEditor.Viewport
// Orthographic
{
var ortho = ViewWidgetButtonMenu.AddButton("Orthographic");
- var orthoValue = new CheckBox(75, 2, _isOrtho);
+ var orthoValue = new CheckBox(80, 2, _isOrtho);
orthoValue.Parent = ortho;
orthoValue.StateChanged += (checkBox) =>
{
@@ -543,7 +554,7 @@ namespace FlaxEditor.Viewport
// Field of View
{
var fov = ViewWidgetButtonMenu.AddButton("Field Of View");
- var fovValue = new FloatValueBox(1, 75, 2, 50.0f, 35.0f, 160.0f, 0.1f);
+ var fovValue = new FloatValueBox(1, 80, 2, 50.0f, 35.0f, 160.0f, 0.1f);
fovValue.Parent = fov;
fovValue.ValueChanged += () => _fieldOfView = fovValue.Value;
ViewWidgetButtonMenu.VisibleChanged += (control) =>
@@ -556,7 +567,7 @@ namespace FlaxEditor.Viewport
// Ortho Scale
{
var orthoSize = ViewWidgetButtonMenu.AddButton("Ortho Scale");
- var orthoSizeValue = new FloatValueBox(_orthoSize, 75, 2, 50.0f, 0.001f, 100000.0f, 0.01f);
+ var orthoSizeValue = new FloatValueBox(_orthoSize, 80, 2, 50.0f, 0.001f, 100000.0f, 0.01f);
orthoSizeValue.Parent = orthoSize;
orthoSizeValue.ValueChanged += () => _orthoSize = orthoSizeValue.Value;
ViewWidgetButtonMenu.VisibleChanged += (control) =>
@@ -569,7 +580,7 @@ namespace FlaxEditor.Viewport
// Near Plane
{
var nearPlane = ViewWidgetButtonMenu.AddButton("Near Plane");
- var nearPlaneValue = new FloatValueBox(2.0f, 75, 2, 50.0f, 0.001f, 1000.0f);
+ var nearPlaneValue = new FloatValueBox(2.0f, 80, 2, 50.0f, 0.001f, 1000.0f);
nearPlaneValue.Parent = nearPlane;
nearPlaneValue.ValueChanged += () => _nearPlane = nearPlaneValue.Value;
ViewWidgetButtonMenu.VisibleChanged += control => nearPlaneValue.Value = _nearPlane;
@@ -578,7 +589,7 @@ namespace FlaxEditor.Viewport
// Far Plane
{
var farPlane = ViewWidgetButtonMenu.AddButton("Far Plane");
- var farPlaneValue = new FloatValueBox(1000, 75, 2, 50.0f, 10.0f);
+ var farPlaneValue = new FloatValueBox(1000, 80, 2, 50.0f, 10.0f);
farPlaneValue.Parent = farPlane;
farPlaneValue.ValueChanged += () => _farPlane = farPlaneValue.Value;
ViewWidgetButtonMenu.VisibleChanged += control => farPlaneValue.Value = _farPlane;
@@ -587,7 +598,7 @@ namespace FlaxEditor.Viewport
// Brightness
{
var brightness = ViewWidgetButtonMenu.AddButton("Brightness");
- var brightnessValue = new FloatValueBox(1.0f, 75, 2, 50.0f, 0.001f, 10.0f, 0.001f);
+ var brightnessValue = new FloatValueBox(1.0f, 80, 2, 50.0f, 0.001f, 10.0f, 0.001f);
brightnessValue.Parent = brightness;
brightnessValue.ValueChanged += () => Brightness = brightnessValue.Value;
ViewWidgetButtonMenu.VisibleChanged += control => brightnessValue.Value = Brightness;
@@ -596,11 +607,26 @@ namespace FlaxEditor.Viewport
// Resolution
{
var resolution = ViewWidgetButtonMenu.AddButton("Resolution");
- var resolutionValue = new FloatValueBox(1.0f, 75, 2, 50.0f, 0.1f, 4.0f, 0.001f);
+ var resolutionValue = new FloatValueBox(1.0f, 80, 2, 50.0f, 0.1f, 4.0f, 0.001f);
resolutionValue.Parent = resolution;
resolutionValue.ValueChanged += () => ResolutionScale = resolutionValue.Value;
ViewWidgetButtonMenu.VisibleChanged += control => resolutionValue.Value = ResolutionScale;
}
+
+ // Invert Panning
+ {
+ var invert = ViewWidgetButtonMenu.AddButton("Invert Panning");
+ var invertValue = new CheckBox(80, 2, _invertPanning);
+ invertValue.Parent = invert;
+ invertValue.StateChanged += (checkBox) =>
+ {
+ if (checkBox.Checked != _invertPanning)
+ {
+ _invertPanning = checkBox.Checked;
+ }
+ };
+ ViewWidgetButtonMenu.VisibleChanged += control => invertValue.Checked = _invertPanning;
+ }
}
// Link for task event
@@ -874,7 +900,11 @@ namespace FlaxEditor.Viewport
protected virtual void UpdateView(float dt, ref Vector3 moveDelta, ref Vector2 mouseDelta, out bool centerMouse)
{
centerMouse = true;
- _camera?.UpdateView(dt, ref moveDelta, ref mouseDelta, out centerMouse);
+ if (_camera != null)
+ {
+ _camera.InvertPanning = _invertPanning;
+ _camera.UpdateView(dt, ref moveDelta, ref mouseDelta, out centerMouse);
+ }
}
///