Author Topic: Cursor locks in UICamera  (Read 1789 times)

Axemagus

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Cursor locks in UICamera
« on: June 25, 2015, 04:16:21 PM »
My project needs the cursor to be visible during regular game play, but also uses shortcut keys.  My problem is that when NGUI detects an input scheme change it locks and unlocks the cursor in the UICamera.currentKey property.  Is there a proper way of dealing with this or is it safe to patch UICamera to alter the lock behavior?

Thanks!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Cursor locks in UICamera
« Reply #1 on: June 25, 2015, 09:25:49 PM »
Shortcut keys should have no effect on the cursor, at least with the latest NGUI. Mouse+Keyboard is the scheme that shows the cursor. Controller and touch are the schemes that hide it.

Axemagus

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: Cursor locks in UICamera
« Reply #2 on: June 25, 2015, 09:54:53 PM »
Right, apologies for not digging deeper into the NGUI code first.

The problem is that WASD triggers a controller/mouse scheme switch. 

I wasn't aware that in some cases key strokes on a keyboard would be treated as controller buttons.  Seems that is the case if they're attached to the navigation axes on the UI camera. Removing the axes from the camera makes the problem go away.

Could you explain the new keyboard/controller logic a bit more or point me toward a guide?

Thanks!


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Cursor locks in UICamera
« Reply #3 on: June 29, 2015, 06:50:36 AM »
It's pretty simple. NGUI uses GetAxis to poll controller axes. If controller input is detected, it switches the scheme accordingly. You define axes in Unity's Input manager.