"Right mouse button+Scroll wheel" will continue to zoom in/zoom out the Scene View instead of changing the camera speed on Unity 2019+
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if UNITY_2019_1_OR_NEWER | |
using UnityEditor; | |
using UnityEngine; | |
[InitializeOnLoad] | |
public class EditorCameraZoomWithScrollWheel | |
{ | |
private const float CAMERA_SPEED = -0.25f; | |
private static bool rmbDown = false; | |
static EditorCameraZoomWithScrollWheel() | |
{ | |
SceneView.beforeSceneGui -= OnScene; | |
SceneView.beforeSceneGui += OnScene; | |
} | |
private static void OnScene( SceneView scene ) | |
{ | |
Event e = Event.current; | |
if( e.isMouse && e.button == 1 ) | |
{ | |
if( e.type == EventType.MouseDown ) | |
rmbDown = true; | |
else if( e.type == EventType.MouseUp ) | |
rmbDown = false; | |
} | |
if( e.isScrollWheel && rmbDown ) | |
{ | |
Vector3 pivot = scene.pivot; | |
pivot += scene.camera.transform.forward * ( e.delta.y * CAMERA_SPEED ); | |
scene.pivot = pivot; | |
e.Use(); | |
} | |
} | |
} | |
#endif |
Sweet baby jesus, thank you for this!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How To
Simply create a folder called Editor inside your Project window and add this script inside it.