Cursors: Krea-Grafiken in voller Auflösung, Blank-Cursor beim Malen, normalisierte Hotspots
- Cursor_Normal/Paint/Pipette: generierte Grafiken jetzt in Vollauflösung (766-829 px, Max Size im Importer steuert Anzeigegröße), Paint-Ring-Inneres freigestellt - Neuer Cursor_Blank (transparent): wird während eines Strokes auf dem Mesh gesetzt statt Cursor.visible zu togglen (fixt Flicker-Kampf mit dem Orbit-Input) - CursorController: Hotspots normalisiert (0-1, unabhängig von Import Max Size); Zustandskette Pipette > (Stroke ? Blank : Paint) > Normal; off-mesh während Stroke -> Normal - MeshPainter: StrokeInProgress-Flag (Maustaste auf Paint-Pfad gehalten) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
653bc79236
commit
423a2d15ec
10 files changed
+160
-20
No files matched your search
@@ -424,6 +424,8 @@ public partial class MeshPainter : MonoBehaviour
|
||||
// --- preview overlay ---
|
||||
/// <summary>True while the brush preview decal is actually drawn this frame (hover hits the paintable surface).</summary>
|
||||
public bool BrushPreviewVisible { get; private set; }
|
||||
/// <summary>True while the paint button is held on the paint path (stroke running). The cursor hides entirely.</summary>
|
||||
public bool StrokeInProgress { get; private set; }
|
||||
public Shader previewShader; // optional; else Shader.Find("Hidden/MeshPaintPreview")
|
||||
private Material _previewMat;
|
||||
private Mesh _previewQuad; // unit quad in the tangent plane (flat decal mode)
|
||||
@@ -855,14 +857,20 @@ public partial class MeshPainter : MonoBehaviour
|
||||
ResolveActiveMask();
|
||||
|
||||
if (!TryGetMouse(out bool pressed, out Vector2 screenPos))
|
||||
{
|
||||
StrokeInProgress = false;
|
||||
return;
|
||||
}
|
||||
|
||||
// Don't paint through the in-game UI (a HUD click must not also stamp the mesh behind it).
|
||||
if (pressed && InputUtil.PointerOverUi())
|
||||
pressed = false;
|
||||
|
||||
// Brush preview at the hover point - independent of painting AND of the pipette, so the
|
||||
// footprint stays visible before pressing, while the pipette holds, and during wheel resize.
|
||||
// While the button is held on the paint path the hardware cursor is hidden entirely
|
||||
// (CursorController); the preview decal itself stays visible during the stroke.
|
||||
StrokeInProgress = pressed && !pipette;
|
||||
|
||||
// Brush preview at the hover point.
|
||||
if (previewMode != BrushPreviewMode.Off && _previewMat && paintCamera)
|
||||
UpdatePreview(screenPos);
|
||||
|
||||
|
||||
@@ -13,14 +13,17 @@ public class CursorController : MonoBehaviour
|
||||
|
||||
[Header("Cursors (import type: Cursor)")]
|
||||
[SerializeField] private Texture2D normalCursor;
|
||||
[Tooltip("Click point inside the texture, in pixels from the top-left.")]
|
||||
[Tooltip("Click point inside the texture, normalized 0-1 from the top-left. Independent of the importer's Max Size.")]
|
||||
[SerializeField] private Vector2 normalHotspot = Vector2.zero;
|
||||
[SerializeField] private Texture2D paintCursor;
|
||||
[SerializeField] private Vector2 paintHotspot = new(16f, 16f);
|
||||
[SerializeField] private Vector2 paintHotspot = new(0.5f, 0.5f);
|
||||
[SerializeField] private Texture2D pipetteCursor;
|
||||
[SerializeField] private Vector2 pipetteHotspot = new(1f, 30f);
|
||||
[SerializeField] private Vector2 pipetteHotspot = new(0f, 1f);
|
||||
[Tooltip("Fully transparent texture shown while a stroke is running - swapping the cursor " +
|
||||
"image avoids fighting the camera rigs over Cursor.visible (which caused flicker).")]
|
||||
[SerializeField] private Texture2D blankCursor;
|
||||
|
||||
private enum State { None, Normal, Paint, Pipette }
|
||||
private enum State { None, Normal, Paint, Pipette, Blank }
|
||||
|
||||
private State _applied = State.None;
|
||||
private CursorMode _appliedMode = CursorMode.Auto;
|
||||
@@ -68,8 +71,11 @@ public class CursorController : MonoBehaviour
|
||||
{
|
||||
if (painter.pipette) want = State.Pipette;
|
||||
// Paint cursor only while painting is actually possible, i.e. the brush preview
|
||||
// decal is drawn at the hover point this frame; hovering off the mesh -> normal.
|
||||
else if (painter.BrushPreviewVisible) want = State.Paint;
|
||||
// decal is drawn at the hover point this frame (hovering off the mesh -> normal,
|
||||
// also mid-stroke). While the stroke touches the mesh the decal alone marks the
|
||||
// brush position -> blank cursor.
|
||||
else if (painter.BrushPreviewVisible)
|
||||
want = painter.StrokeInProgress ? State.Blank : State.Paint;
|
||||
}
|
||||
|
||||
var mode = CursorMode.Auto;
|
||||
@@ -83,12 +89,21 @@ public class CursorController : MonoBehaviour
|
||||
|
||||
switch (want)
|
||||
{
|
||||
case State.Paint: Cursor.SetCursor(paintCursor, paintHotspot, mode); break;
|
||||
case State.Pipette: Cursor.SetCursor(pipetteCursor, pipetteHotspot, mode); break;
|
||||
default: Cursor.SetCursor(normalCursor, normalHotspot, mode); break;
|
||||
case State.Blank: Apply(blankCursor, Vector2.zero, mode); break;
|
||||
case State.Paint: Apply(paintCursor, paintHotspot, mode); break;
|
||||
case State.Pipette: Apply(pipetteCursor, pipetteHotspot, mode); break;
|
||||
default: Apply(normalCursor, normalHotspot, mode); break;
|
||||
}
|
||||
}
|
||||
|
||||
private static void Apply(Texture2D cursor, Vector2 normalizedHotspot, CursorMode mode)
|
||||
{
|
||||
var hotspot = cursor
|
||||
? Vector2.Scale(normalizedHotspot, new Vector2(cursor.width, cursor.height))
|
||||
: Vector2.zero;
|
||||
Cursor.SetCursor(cursor, hotspot, mode);
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto); // back to the OS cursor
|
||||
|
||||
Reference in new issue
Block a user