Author Topic: How to get raycast and selected object using UICamer.OnCustomInput  (Read 3404 times)

maaya

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 22
    • View Profile
How to get raycast and selected object using UICamer.OnCustomInput
« on: September 16, 2014, 01:18:14 PM »
Hi,

I am trying to port a fully working NGUI game to Ouya and running into some murky waters.
From some of the Ouya reference posts on this forum, I tried using CustomInput for the UICamera like so:

UICamera.onCustomInput += OuyaInput;

And in the function, I am able to capture the controller button clicks and axis values.

I am a little lost as to
1. how to translate the axis values and button clicks (say O-button click) so NGUI can set the UICamera.selectedobject and trigger OnPress/OnDrag etc.

2. if this needs to be added to every single button and object in the game which works with drag-drop or if I can have a central script that can interface with NGUI.

3. I noticed the Input.GetKey and Input.GetAxis are function pointers in UICamera. Can they be overridden to get data from Ouya in that environment?

Any help is much appreciated.
« Last Edit: September 16, 2014, 02:56:08 PM by maaya »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How to get raycast and selected object using UICamer.OnCustomInput
« Reply #1 on: September 17, 2014, 11:49:50 AM »
Yes, you can and should overwrite those GetKey and GetAxis methods. You can react to Ouya events and translate them to axis movements and Return key presses. Taking this route you don't even need to write anything for onCustomInput.