Input.GetAxis("Mouse ScrollWheel") not working without wheel being clicked in

So, is there anyone else with this problem?
I currently have
var num = Input.GetAxis(“Mouse ScrollWheel”)
Camera.main.orthographicSize -= num;
Debug.Log(num);

Debug shows a constant zero when I scroll, only outputting non-zeros if I click in the scrollwheel and scroll at the same time.

Occurs on Logitech M215 Unifying mouse, M557 Bluetooth mouse, and Asus I2C interface trackpad

@ericchen1248 , @tonytopper

public float minSize, maxSize;
public float zoomSensitivity;
    
public void CamZoom()
    {
        float fov = Camera.main.orthographicSize;
    
        fov -= Input.GetAxis("Mouse ScrollWheel") * zoomSensitivity;
    	fov = Mathf.Clamp(fov, minSize, maxSize);
    	Camera.main.orthographicSize = fov;
    }

I had this issue, and for me the culprit was something I’d put in to cut down on individual checks for various keyboard inputs: if(!Input.anyKey) return;.

anyKey is a bool which returns “is any key or mouse button currently held down”. This includes all keyboard and mouse buttons, but (with my mouse at least) does not include scrolling the mouse wheel. Pressing in the mouse wheel does count as a button press, so bypasses the anyKey check, as described by the OP.

If this anyKey thing is your issue then the solutions are simple…

Solution 1 - Place your code for mouse scrollwheel above the anyKey check:

private void Update () {
	// Code to process your scrollwheel input here
	if (!Input.anyKey) {
		// No keyboard or mouse buttons are currently being pressed, skip further checks
		return;
	}
	// Code to process mouse/keyboard input here
}

Solution 2 - Add an extra check specifically for the scroll wheel with mouseScrollDelta

private void Update () {
	if (!Input.anyKey && Input.mouseScrollDelta == Vector2.zero) {
		// No keyboard or mouse buttons are currently being pressed, skip further checks
		return;
	}
	// Code to process mouse/keyboard/scrollwheel input here
}