Author Topic: UISlider, game controllers, and OnPress  (Read 1971 times)

Johnnemann

  • Guest
UISlider, game controllers, and OnPress
« on: November 05, 2012, 12:55:08 AM »
Hi!

I had a problem with UISliders when used with a gamepad. Pressing the Confirm button would make the slider value 0 - this is because "OnPress" on the slider tries to figure out where the mouse pointer is on the slider to set the thumb correctly, and with a gamepad there's no mouse pointer, so it ends up defaulting to 0.

I fixed this in the following way in the UISlider code, Line 143:

void OnPress (bool pressed) { if (pressed && (UICamera.mainCamera.GetComponent<UICamera>()).useMouse) UpdateDrag(); }

This works for me, as gamepad and mouse are mutually exclusive.

Anyway, I am posting this here so that this can be fixed in the next version of NGUI, and so that the answer is out there if anyone needs it.

Thanks!

Johnnemann

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UISlider, game controllers, and OnPress
« Reply #1 on: November 05, 2012, 04:44:27 AM »
I will look into it, thanks.