I recently switch from Maya to Blender, and I love that I can easily pan around with “Alt+Shift+Left Click” instead of the standard “Middle Click” pan. Many computer mice have awkward middle click buttons, and I’ve found that the “Alt+Shift+Left Click” shortcut in Blender is far easier for me to use.
Currently “Shortcuts” in Unity only allow keyboard input and there is no “3D Viewport/Pan” command to replace. It’d be awesome if Unity could add a “3D Viewport/Pan” command and allow mouse input to be combined with keys in Shortcuts.
I created an AutoHotkey script that maps “Alt+Shift+Left Click” to a Middle Click hold, but I can’t get it to feel as smooth as Unity’s Middle Click pan, which is why I made this feature request. If you want to run the script for yourselves, save the attached text file as a .ahk and run it with AutoHotkey. Thanks!
alright, I did some refinement with chatgpt and got a working script for the controls I wanted (pan: shift + alt + left click, zoom: ctrl + alt + left click. just like in Blender). if someone wants to use their own controls they can either dive into the code or ask chatgpt to change it. sensitivity is adjusted with the ‘5f’ and ‘.002f’ values
using UnityEditor;
using UnityEngine;
[InitializeOnLoad]
public class SceneViewControls : MonoBehaviour
{
private static bool isPanning;
private static bool isZooming;
private static Vector2 lastMousePosition;
static SceneViewControls()
{
SceneView.duringSceneGui += OnSceneGUI;
}
private static void OnSceneGUI(SceneView sceneView)
{
Event e = Event.current;
switch (e.type)
{
case EventType.MouseDown:
if (e.button == 0 && e.shift && e.alt) // Shift + Alt + Left Click for panning
{
isPanning = true;
lastMousePosition = e.mousePosition;
e.Use();
SceneView.RepaintAll(); // Repaint to update cursor
}
else if (e.button == 0 && e.control && e.alt) // Ctrl + Alt + Left Click for zooming
{
isZooming = true;
lastMousePosition = e.mousePosition;
e.Use();
}
break;
case EventType.MouseUp:
if (e.button == 0)
{
if (isPanning)
{
isPanning = false;
e.Use();
SceneView.RepaintAll(); // Repaint to update cursor
}
else if (isZooming)
{
isZooming = false;
e.Use();
}
}
break;
case EventType.MouseDrag:
if (isPanning)
{
Vector2 delta = e.mousePosition - lastMousePosition;
delta /= sceneView.size * 5f;
Vector3 move = new Vector3(-delta.x, delta.y, 0); // Adjust for both X and Y
sceneView.pivot += sceneView.rotation * move;
lastMousePosition = e.mousePosition;
e.Use();
}
else if (isZooming)
{
float zoomDelta = e.delta.y * .002f; // Reverse the zoom direction
sceneView.size *= Mathf.Exp(zoomDelta);
lastMousePosition = e.mousePosition;
e.Use();
}
break;
}
}
}