Add in-game paint HUD bound to the mesh painter

Add a code-driven HUD that appears in paint mode and binds live to the
active MeshPainter: four channel toggles, HSV pickers for albedo and
emission, sliders for metallic/smoothness/occlusion, emission intensity
and brush size. The HUD self-assembles its own overlay canvas and event
system at runtime.

Add a ModeChanged event to GameModeManager so the HUD can follow the
active mode, and guard MeshPainter against painting through the UI.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
adminandClaude Opus 4.8 committed 2026-06-24 08:26:56 +02:00
1 parent 6555db1487
commit 04c22f0ac1
8 files changed
+594

No files matched your search

+13
View File
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
#if ENABLE_INPUT_SYSTEM
using UnityEngine.InputSystem;
#endif
@@ -578,6 +579,11 @@ public partial class MeshPainter : MonoBehaviour
if (!TryGetMouse(out bool pressed, out Vector2 screenPos))
return;
// Don't paint through the in-game UI: clicking a HUD slider/toggle must not
// also stamp the mesh behind it.
if (pressed && IsPointerOverUi())
pressed = false;
// Brush preview (size + mask) at the hover point - independent of painting,
// so you see the brush before pressing the button.
if (previewMode != BrushPreviewMode.Off && _previewMat && paintCamera)
@@ -741,6 +747,13 @@ public partial class MeshPainter : MonoBehaviour
#endif
}
/// <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 void OnDestroy()
{
if (_bakedMesh) Destroy(_bakedMesh);