Author Topic: UICamera.ProcessMouse() not respecting Screen.showCursor  (Read 6892 times)

Paul

  • Newbie
  • *
  • Thank You
  • -Given: 5
  • -Receive: 0
  • Posts: 22
    • View Profile
UICamera.ProcessMouse() not respecting Screen.showCursor
« on: July 18, 2015, 01:35:07 AM »
Apologies for my ignorance, as this is likely an error on my part.

I noticed UICamera.ProcessMouse() is still running logic, even when the mouse cursor is not visible. This leads to mouse over events firing and UICamera.selectedObject changing based on an invisible mouse cursor.

To give an example, I'm using Screen.showCursor and Screen.lockCursor to hide & lock the mouse when in gameplay, and to show & unlock the mouse in the pause menu. This works fine, but I also show a few in-game NGUI menus that are only navigable via keyboard/controller input, so the mouse remains locked & hidden invisibly in the center of the screen. However, if one of these menus appears in the center of the screen, the invisible mouse cursor will send events to the menu. This behavior seems strange, as I would not expect mouse processing when the mouse is not visible.

I'm running NGUI 3.8 on Unity 4.3 (stuck on an older version due to WiiU compatibility) but still developing for PC & Mac with the same project.

I should note that adding the following to the top of UICamera.ProcessMouse() seems to fix the issue, but I'd like to run it by the community first, thanks!

  1. if (!Screen.showCursor) return;

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UICamera.ProcessMouse() not respecting Screen.showCursor
« Reply #1 on: July 21, 2015, 11:23:14 AM »
If you are using multiple forms of input, you really owe it to yourself to update your version of NGUI. NGUI 3.9 completely revamped the way multiple forms of control get mixed together, simplifying everything greatly. It will also automatically hide the mouse when you start using touch or controller-based input. It shouldn't be too difficult to adapt the current version of NGUI to Unity 4.3.

Darkness

  • Jr. Member
  • **
  • Thank You
  • -Given: 3
  • -Receive: 0
  • Posts: 90
    • View Profile
Re: UICamera.ProcessMouse() not respecting Screen.showCursor
« Reply #2 on: July 25, 2015, 05:59:06 AM »
If you are using multiple forms of input, you really owe it to yourself to update your version of NGUI. NGUI 3.9 completely revamped the way multiple forms of control get mixed together, simplifying everything greatly. It will also automatically hide the mouse when you start using touch or controller-based input. It shouldn't be too difficult to adapt the current version of NGUI to Unity 4.3.

Whoa.  I think this is what's causing the wonky mouse problems I've been having recently.  Is there a way to turn this off?  My game allows the player to use whatever control device they want and some people use a combination of keyboard, controller, and mouse.  Lately, the mouse keeps disappearing and won't come back unless a certain menu is clicked again.  It didn't use to do this and is extremely annoying. 

devomage

  • Sr. Member
  • ****
  • Thank You
  • -Given: 7
  • -Receive: 67
  • Posts: 250
    • View Profile
Re: UICamera.ProcessMouse() not respecting Screen.showCursor
« Reply #3 on: July 25, 2015, 03:54:00 PM »
It didn't use to do this and is extremely annoying.


a lot of complaints about this.  yes, it is very annoying.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UICamera.ProcessMouse() not respecting Screen.showCursor
« Reply #4 on: July 27, 2015, 08:21:29 PM »
Just comment out lines 503, 504, 506 and 507 of UICamera.cs.
  1. #if UNITY_4_3 || UNITY_4_5 || UNITY_4_6
  2.                                                 //Screen.showCursor = false;
  3.                                                 //Screen.lockCursor = true;
  4. #else
  5.                                                 //Cursor.visible = false;
  6.                                                 //Cursor.lockState = CursorLockMode.Locked;
  7. #endif