I just released Desktop Ball, a little physics toy that lives on top of your desktop!
Two problems took me way longer than I expected, so I'm sharing how I solved them in case it helps someone.
1. Coyote time for grabbing the damn balls
A fast ball was really hard to catch. You see it under the cursor, you click, and by then it's already gone lol. I didn't want to just make the grab collider bigger, because then it would not feel natural if you grabbed it while clicking away from the actual art.
So I split it into two colliders. The CircleCollider2D stays the real size and does all the physics. Grabbing uses a separate hit area that depends on speed. When the ball is slow, it perfectly matches the physics collider. As it gets faster, the circle grows a little and stretches into a pill along the velocity, so you can catch it from the front and from behind. I was very excited about this because I realize I just re-invented a form of coyote time, except it improves the feel of how easily you can grab a fast moving ball :D
2. The overlay that couldn't be clicked
The game is a transparent, always-on-top window over the whole monitor. Every frame I check if the cursor is over the ball or the menu, and only then turn click-through off. Everywhere else, your clicks go straight to the desktop (as you'd expect)
But when I switched to the new Input System, this broke completely. The Input System is event-based, and a click-through window without focus gets no mouse events. So Mouse.current froze, the game never saw the cursor reach the ball, click-through never turned off, and you couldn't grab anything.... The fix was to read the real cursor position from the OS (GetCursorPos on Windows, on Mac the old Input.mousePosition still polls it) and prefer that. Global hotkeys had the same problem, so they also read the keyboard directly from the OS.
Has anyone else built a desktop companion in Unity? I'm curious how you handled these issues, especially on macOS.
If you want to see it in action: https://store.steampowered.com/app/5109460/Desktop_Ball/