From Unity to Ouya – Quick Setup guide

The lack of some centralized info about how to get your Unity game running on the Ouya with controller support has lead me to write this post. I spent a lot of time reading over at the ouya dev site, ouya forums, github, social networks, blogs… and I finally got it working!

Getting the OUYA-Unity plugin ready:
  1. Grab the source from github.
  2. Open Unity and tell it to open the project you’ve just downloaded in step 1.
  3. Click on “OUYA > Export Core Package“.
  4. Open your game project and click on “Assets > Import Package > Custom Package“. Import all content. Beware that this package includes an “Input Manager.asset” which will overwrite all your custom input you may have in “Edit >Project Settings > Input“. Since there is no “merge” that I know of, I just took a couple screenshots of my current input manager, imported the ouya one, and then added back the custom controls I had before using the screenshots as reference.
  5. Click on “Window > Open OUYA Panel“. The first thing you’ll probably notice is a warning:  ”[error] Bundle mismatched”. Write your desired bundle ID and click on “Sync Bundle ID“. Error should be gone.
  6. There are several tabs at the top. Go check them all, if you find something grayed out it means that it’s missing so you’ll need to download the according library (or just select its path if you have it already).
  7. Update Android SDK to API 16 using the Android SDK Manager. Android SDK Tools should be rev.21, do not update it to rev.22.
  8. Android NDK path should not contain any spaces (otherwise it will throw an error). Also, version r8d needs a fix in the file ndk/build/gmsl/__gmsl - Open it with a text editor and replace line 512 with the following:
    int_encode = $(__gmsl_tr1)$(wordlist 1,$(words $1),$(__gmsl_input_int))
  9. Click on “Compile” (in Ouya Panel). The ODK is now ready to be used.
  10. Drag & drop “OuyaGameObject” prefab from the imported Prefabs folder into your initial scene. This object will be persistant across all your levels so it should be in a scene previous to your main menu, so it gets loaded just 1 time.
  11. Grab your developer ID from here and put it in the available slot in “OuyaGameObject” prefab in your scene.
  12. Remember to publish your .apk targeting API 16 or above!
Getting the OUYA recognized as an Android device under Windows 7:
  1. Connect your OUYA via USB to your computer. You’ll be able to access the device as a media device but one driver will fail so the device will not be seen by Unity / adb. Let’s fix that.
  2. Open the root folder of your Android SDK and navigate to “extras/google/usb_driver/android_winusb.inf”. Open it with a text editor and add the following text under both the [Google.NTx86] and the [Google.NTamd64] sections:
    ;OUYA Console
    %SingleAdbInterface%        = USB_Install, USB\VID_2836&PID_0010 
    %CompositeAdbInterface%     = USB_Install, USB\VID_2836&PID_0010&MI_01
  3. Go to your Windows Device Manager. Right click on the OUYA > “Update driver” > “Browse my computer” > “Pick from a list” > “Have disk” > Now go select the file you edited in step 2, and install it as “Android composite ADB Interface“.
  4. OUYA device is ready!
Getting the controller to work:
  1. Download “SuperInputMapper.cs” by Sophie Houlden (and say thanks to her! @S0phieH) and put it in your project. If you are using UnityScript, this needs to go in the “Plugins” folder.
  2. You can query button presses like this:
    if(SuperInputMapper.GetButtonDown(OuyaSDK.KeyEnum.BUTTON_DPAD_RIGHT, OuyaSDK.OuyaPlayer.player1)) moveRight();

    And query axis like this:

    axisValue = SuperInputMapper.GetAxis(OuyaSDK.KeyEnum.AXIS_LSTICK_X, OuyaSDK.OuyaPlayer.player1);


  3. Quick reference of button names:
Getting the controller to work… with NGUI’s uibuttonkeys:
  1. Update NGUI to the latest version so you don’t need to hack into uicamera.cs (this was needed before the update).
  2. UICamera.onCustomInput will allow you to pass a custom function that will be processed by NGUI with the rest of the input (keyboard, touch…). You just need to write this:
    UICamera.current.onCustomInput = yourFunction;

    And then create a function that processes OUYA Input and passes it to NGUI using UICamera.Notify. Here it’s the complete script I’m using, if it’s of any help.

This is it. I tried to keep this guide extra-concise so you can quickly get a grasp of what’s going on. If you struggle at some point, you can check any of the following links since they are the main source where I’ve gathered all this data:

Publishing to ouya from unity3d
Setting up ouya for unity
Official OUYA Docs on Github
Official OUYA-Unity docs
Official OUYA forums
Timothy Graupmann’s Youtube Channel

P.S.: There is a new Controller Framework being developed, I haven’t looked at it yet but here it is if you want to give it a try.

Add a Comment