Search Unity

5.3.1: canvas doesn't process mouse events on part of the screen (full screen + multi-monitor)

Discussion in 'UGUI & TextMesh Pro' started by rzubek, Dec 18, 2015.

  1. rzubek

    rzubek

    Joined:
    Aug 21, 2014
    Posts:
    72
    I just filed bug #755480 for a bug with full screen mode in a multi-monitor setup. Parts of the canvas stop responding to mouse events, based on the *other* monitor's resolution. It's related to the regression introduced in 5.3.0, which it appears wasn't completely fixed in 5.3.1.

    I have a Win10 computer with two monitors. Left one is rotated (effective resolution 1080x1920) while right one is standard (1920x1080). Windows identifies right one as #1, left one as #2.

    Problems:

    1. When I start the game in full screen mode, the resolution picker incorrectly identifies the *left* one as the default ("display 1") and starts the game there.

    2. Much bigger problem: if I start the game on the right display (called "display 2" by unity), canvas UI covers the entire 1920x1080 screen, but only responds to mouse events on the left half of the screen. Specifically, it only responds to mouse events with x < 1080. Events at x>1080 don't seem to get processed at all.

    As far as I can tell, the only option for the user is to run in windowed mode, because half of the screen is not responsive to mouse clicks.

    (I *think* the culprit is that Unity incorrectly identifies the right display as #2, while Windows identifies it as #1, and they get confused about what is its actual resolution.)
     

    Attached Files:

    Cromfeli likes this.
  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,297
    Multi display mode is disabled for the ui in 5.3.1 so its highly likely this is the reason. The multi display system is unreliable for reporting resolutions which is why we disabled it while we wait for it to be sorted. I'll take a look at your bug to be sure when I get a chance.
     
  3. rzubek

    rzubek

    Joined:
    Aug 21, 2014
    Posts:
    72
    Thank you for the fast response! So is there any way to bypass this multi display system and restore how the game used to work in 5.2? I'm afraid that players might run into this in the wild.
     
  4. phil-Unity

    phil-Unity

    Unity UI Lead Developer

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    5.3.1 is out now so you can update and it will be fine.
     
  5. phil-Unity

    phil-Unity

    Unity UI Lead Developer

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    So i'm checking into something as they might not have fully disabled the multiscreen stuff which could effect the mouse position

    EDIT: yea one part wasn't turned off that we forgot was added. If you need a fix before early in the new year i'd recommend grabbing the source and implementing the fix yourself.

    FIX for those who care:
    So in GraphicRaycaster.cs there is a couple lines related to multi screen within the Raycast function. If you grab the 5.2 version of that whole class you should be ok. The other option is to just replace those lines with "pos = new Vector2(eventData.position.x / Screen.width, eventData.position.y / Screen.height);" if you feel more comfortable.
     
    Last edited: Dec 18, 2015
    karl_jones likes this.
  6. rzubek

    rzubek

    Joined:
    Aug 21, 2014
    Posts:
    72
    I see, line 85 in GraphicRaycaster.cs - thank you! Just the tip I was looking for! :)

    https://bitbucket.org/Unity-Technol...GraphicRaycaster.cs?diff2=5e765793e9b5&at=5.3
     
    karl_jones likes this.
  7. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,297
    Pro tip
    Instead of downloading the ui source create a new class that inherits from graphic raycaster and just override that function and swap the raycaster out of the event system for your new one. I'll post the code here when i get a chance.
     
    holliebuckets and phil-Unity like this.
  8. rzubek

    rzubek

    Joined:
    Aug 21, 2014
    Posts:
    72
    Awesome, thank you!
     
    holliebuckets likes this.
  9. silentslack

    silentslack

    Joined:
    Apr 5, 2013
    Posts:
    395
    Hi,

    I'm having trouble with Canvas raycasting in Unity 5.4 - should this be fixed in this version? My game changes which display the canvas is drawn to during runtime. Although the canvas is drawing fine the click events are not, it almost looks like it's reacting to click events in the wrong screen size.

    Thanks!
     
  10. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,297
    The UI system does not currently support multi display so if its not on the primary display it wont work correctly including input events. We had to disable the system in 5.3 due to a significant bug which is still not fixed
     
  11. silentslack

    silentslack

    Joined:
    Apr 5, 2013
    Posts:
    395
    Ok that's fair enough. Is it on the roadmap to be fixed and any idea when that could be?
     
  12. silentslack

    silentslack

    Joined:
    Apr 5, 2013
    Posts:
    395
    Also, just to confirm what is considered the "Primary Display"? I seem to get some confusing outcomes when running -multidisplay. Is the primary the display that started up Unity or what Windows considers monitor identity 1 (in Display Properties)?

    I seem to get the impression that it's what Windows identifies as 1 - this is an issue as Windows doesn't let you change this from what I can tell.
     
  13. rzubek

    rzubek

    Joined:
    Aug 21, 2014
    Posts:
    72
    I've run into this bug as well. A game seems to want to start on logical display #1, even when #1 is not set in Windows as the main display. And I believe you're correct, Windows doesn't let you renumber them.

    This started happening with the (now disabled) multi-display code, ~5.2 or so.

    Also I don't think there's a way to detect if you're displaying on the wrong monitor from inside the application, so you could at least give the player a hint to manually move the game to the other monitor...?
     
  14. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,297
    rzubek likes this.
  15. silentslack

    silentslack

    Joined:
    Apr 5, 2013
    Posts:
    395
    @karl.jones Hi Karl, are you aware if there is any update on the issue with the primary monitor bug? Or perhaps a ETA when a fix is likely to be?

    Thanks!
     
  16. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,297
    Hi,
    Its been fixed. I have added it to our backport queue for 5.3 and 5.4 so it should be out in an upcoming patch.
     
  17. silentslack

    silentslack

    Joined:
    Apr 5, 2013
    Posts:
    395
    Amazing! I'll look out for it. Hopefully this fixes the issues I'm having.

    Thank you.
     
  18. zivschneiderz

    zivschneiderz

    Joined:
    May 2, 2015
    Posts:
    6
    Should this be working in 5.6?

    thanks!
     
  19. Rational-MA

    Rational-MA

    Joined:
    Mar 6, 2015
    Posts:
    59