Fix: wheel over UI scrolls the list instead of zooming the camera

The orbit rig read the wheel unfiltered for zoom, so scrolling a paint-mode
scroll list also zoomed the camera. Gate the zoom behind a shared
InputUtil.PointerOverUi() helper (EventSystem raycast); MeshPainter's private
IsPointerOverUi() now delegates to the same helper (DRY).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
adminandClaude Opus 4.8 committed 2026-07-03 16:04:51 +02:00
1 parent a4604328d2
commit 50efc7e8b3
3 files changed
+18 -11

No files matched your search

@@ -238,11 +238,13 @@ public class ThirdPersonOrbitInput : MonoBehaviour
float scale = CurrentScale();
// Shift/Ctrl+wheel is reserved for the paint brush resize (MeshPainter) - but only in paint
// mode (PanEnabled), where the resize actually claims the wheel. Outside paint mode Shift is
// the sprint key, so the wheel must still zoom.
bool brushResizeClaimsWheel = PanEnabled && (InputUtil.ShiftHeld() || InputUtil.CtrlHeld());
float scroll = brushResizeClaimsWheel ? 0f : InputUtil.ReadScroll();
// The wheel belongs to the UI when the pointer is over an interactive element (e.g. a scroll
// list), so it scrolls the UI instead of zooming. Shift/Ctrl+wheel is likewise reserved for the
// paint brush resize (MeshPainter) - but only in paint mode (PanEnabled), where the resize
// actually claims the wheel; outside paint mode Shift is the sprint key, so the wheel must zoom.
bool wheelClaimed = InputUtil.PointerOverUi()
|| (PanEnabled && (InputUtil.ShiftHeld() || InputUtil.CtrlHeld()));
float scroll = wheelClaimed ? 0f : InputUtil.ReadScroll();
if (!Mathf.Approximately(scroll, 0f))
{
// One wheel notch = one zoom step (sign only, platform-independent). The step scales with
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
#if ENABLE_INPUT_SYSTEM
using UnityEngine.InputSystem;
#endif
@@ -1123,11 +1122,7 @@ public partial class MeshPainter : MonoBehaviour
}
/// <summary>True if the pointer is currently over an interactive UI element (raycast target).</summary>
private static bool IsPointerOverUi()
{
var es = EventSystem.current;
return es && es.IsPointerOverGameObject();
}
private static bool IsPointerOverUi() => InputUtil.PointerOverUi();
private void OnDestroy()
{
+10
View File
@@ -1,4 +1,5 @@
using UnityEngine;
using UnityEngine.EventSystems;
#if ENABLE_INPUT_SYSTEM
using UnityEngine.InputSystem;
#endif
@@ -40,6 +41,15 @@ public static class InputUtil
Cursor.visible = !locked;
}
/// <summary>True while the pointer is over an interactive UI element (a raycast target), so the
/// wheel/click belongs to the UI (e.g. a scroll list) and must not also zoom the camera or paint
/// the mesh behind it. False when no EventSystem exists.</summary>
public static bool PointerOverUi()
{
var es = EventSystem.current;
return es && es.IsPointerOverGameObject();
}
public static bool ShiftHeld()
{
#if ENABLE_INPUT_SYSTEM