Sketch Get Mouse Position
Get the current mouse position in sketch coordinates, similar to Processing's mouseX and mouseY.
Parameters
| Parameter | Description |
|---|---|
| Sketch Component | Sketch canvas to read from. |
| Camera | Optional camera used to convert the screen position to the sketch surface. Leave empty to use Camera.main for SpriteRenderer output. |
| X | Optional output for mouse X in sketch coordinates. |
| Y | Optional output for mouse Y in sketch coordinates. |
| Position | Optional output for mouse position as a Vector2. |
| Success | Optional output that is true if the conversion succeeded. |
Notes
- This is especially useful for interactive drawing and hover effects.
- For UI sketches shown with a
RawImage, the camera should match the UI setup when needed. - For world-space sketches shown with a
SpriteRenderer, leaving Camera empty usesCamera.main.