Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Unity WebGL build does not detect mouse clicks on part of screen

A topic by Will9371 created Feb 09, 2024 Views: 476 Replies: 3
Viewing posts 1 to 3

I have a Unity application (https://will9371.itch.io/probability-calculator for reference) that works fine in the editor, standalone build, and locally on WebGL (on selecting "Build and Run"), but does not detect mouse clicks on part of the screen when uploading the WebGL build to Itch.  Maximizing the screen usually fixes the problem, and it usually stays fixed when leaving fullscreen mode.  Error persists across browsers.  I have verified that there are no invisible objects on the parts of the screen that don't detect clicks.  Any ideas what might be happening?

I've tried experimenting with different viewport dimensions and WebGL template image (Minimal seems to work better than Default for some reason), and sometimes the dead space is an invisible box in the lower middle of the screen rather than the whole screen, but I have not found any settings that make the issue go away.

(+1)

I experienced similar issues once: I used UI-Toolkit for the UI and in the WebGL build I could not detect clicks on 3D objects. It seemed that UI-Toolkit was "blocking" the mouse with invisible UI-Elements that should not be there. I was able to workaround this by using "abolute" positioning for top-level UI-Elements.

Thanks!  I am using Unity's built-in UI without plugins.  I've modified the elements that were previously set to stretch to no effect, but I'll keep experimenting.

(+1)

My initial thought was maybe you were missing an event systems but after looking at your app, I feel like there might be an issue with the Canvas scale. I've experienced issues like this before where I click at a position on the screen (such as [0,0,0]) but unity detects the click at a different position (such as [15, 129, 0])

I recommend logging clicks to see where unity thinks the position of the mouse is verses the position of the button. 

Another recommendation is to instantiate a colored cube on click to see exactly where Unity is finding the click position.

Best of luck with the issue.