Author Topic: Controlling a Grid using a gamepad  (Read 3026 times)

cygnus

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 12
    • View Profile
Controlling a Grid using a gamepad
« on: March 19, 2014, 05:46:54 AM »
Hi all,

I'm having trouble making a grid controllable by a gamepad. I'm using NGUI 3.4.7 and the example scene is working and so I adapted by project to match the example but no luck.
After debugging I noticed the UICamera.selectedObject is always NULL even if the statement before this check I assign the selectedObject with the first in the list (having startSelected = true).

I also noticed the gamepads down and up keys (vertical grid) are properly captured in the UIButtonKeys assigned to all my items within the grid. Bedore you ask: the selectOnUp and selectOnDown properties for all items are properly assigned.

Did I miss something?

cygnus

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 12
    • View Profile
Re: Controlling a Grid using a gamepad
« Reply #1 on: March 19, 2014, 09:36:11 AM »
Upgraded the project to the latest NGUI 3.5.4 r2 but the issue still exists. Somebody any clue what's missing?

cygnus

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 12
    • View Profile
Re: Controlling a Grid using a gamepad
« Reply #2 on: March 19, 2014, 02:13:38 PM »
Ok, works if I assign a scripts that centers the selected object in the scrollview. Is there a way to have a 'normal' scrolling (only scroll when on the bottom or top of the list) iso always centering on the selected item?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Controlling a Grid using a gamepad
« Reply #3 on: March 20, 2014, 01:24:59 AM »
Via a custom script that will check the position of the selected object versus the scroll view's rectangle.

Btw, to scroll the scroll view, the easiest thing to do would be to detect specific joystick/controller keys in Update, and using SendMessage("OnScroll", delta * Time.deltaTime) to the scroll view.