Hi Tim,
I'm just starting my game from scratch, and following your examples on the Ouya website, at first I set my input handling code up like this:
private void HandleButtonEvent(OuyaSDK.OuyaPlayer p, OuyaSDK.KeyEnum b, OuyaSDK.InputAction bs)
{
if (b.Equals(OuyaSDK.KeyEnum.BUTTON_O) && bs.Equals(OuyaSDK.InputAction.KeyDown))
{
//Do something
}
}
...but then after reading here in the forums, I decided to switch to native Unity input handling before going any further. So in my Update() I put:
if(Input.GetKeyDown(OuyaSDK.KeyEnum.BUTTON_O))
{
//Do something
}
And that doesn't work. Unity says "Argument `#1' cannot convert `int' expression to type `string'".
Should I be using your provided key codes when using native Unity input, and if so, how do you recommend I do that? Sorry if this has been answered somewhere else. I know there are a lot of questions about this here on the forums, but I couldn't find a post that clarified this.
Answers
I don't think you can use those enums when using the Unity input, this is (basically) what I do:
if (Input.GetKeyDown((KeyCode)OuyaKeyCode.JoystickButton0))
{
}
(or Joystick1Button0, Joystick2Button0, etc.) Button0,1,2,3 = O,U,Y,A, Button4,5 are the shoulder buttons, Button6,7 are clicking the two analogue sticks in, Button8,9,10,11 are the d-pad.
if(Input.GetKey(KeyCode.JoystickButton0))
{
//Do something
}
OUYA Inc | Android Developer
Skype: tgraupmann_prey
http://github.com/ouya/docs
http://github.com/ouya/ouya-sdk-examples
Check out the latest docs for your game engine: [setup] [adobe air] [android] [clickteam fusion] [construct 2] [corona] [libGDX] [game maker] [html5] [marmalade] [monogame] [unity] [unreal]
Use caution when setting [persistent wireless mode].