Jun
26
2013

Publishing to OUYA from Unity3D

ouya_unity3d

Huh took some time to setup Unity (indie or pro) to work with OUYA.
Most of these notes are from the official documentation, the forum and other blogs,
i’ve just collected all the steps that it took me to install everything. (it was quite a mess!)

Download PDF:
OUYA_Unity3D_notes.pdf

Links:
List of Unity and Ouya tutorials (ouya forums)
Setting Up OUYA for Unity (many of the steps are from here) (third-helix.com blog)
Ouya Docs Windows Related stuff (ouya github)
Fix for the missing aapt.exe path (ouya forums)
OUYA Devs Docs For Unity (ouya devs)
Ouya with Unity *New tutorial Steve Tack’s Lab
From Unity to Ouya (tutorial, thinicegames blog)
OuyaInput Controller Framework (ouya forums)

*** blog broke the text layout below.. use the PDF instead ^ **

OUYA & Unity

JAVA

–          Download Java (JRE): http://www.java.com/en/download/ie_manual.jsp?locale=en

  • SDK Manager won’t run in next step if you don’t have java se/jre
  • Install it
  • *Don’t install the  toolbar it offers..


 

ANDROID SDK

–          Download sdk bundle: http://developer.android.com/sdk/index.html

  • I downloaded the x64 version (adt-bundle-windows-x86_64-20130522), 32bit one seemed to work also

–          Unzip the downloaded files somewhere

  • I used C:\progs\adt-bundle-windows-x86_64-20130522

–          Go inside that folder “adt-bundle-windows-x86_64-20130522”

–          Run “SDK Manager.exe”

  • If it doesn’t start, install Java first ^

–          Install the files shown in this image as installed, select them and press Install packages

  • I kept pressing Install packages until it didn’t appear again (I guess it was updating them?)

–          Note. You can uninstall the API17 (or other not used items) by selecting them and pressing “Delete # Packages” button

–          Close “SDK Manager”

WINDOWS (using 7 here, apparently with 8 you need to do something’s differently..)

Setup path environment variables for java bundle

–          Go to Control panel (windows)

–          System

–          Advanced System Settings

–          (press Yes to allow, if user account control pops in)

–          In that Advanced tab, press button “Environment Variables”

–          It opens new window “Environment Variables”

–          In user variables list, if you have there  variable “PATH” (or “path”..), select it

–          Press Edit

–          You can now edit the variable value add to the end of line (in that very small window..)
;C:\progs\adt-bundle-windows-x86_64-20130522\sdk\tools; C:\progs\adt-bundle-windows-x86_64-20130522\sdk\platform-tools; C:\progs\adt-bundle-windows-x86_64-20130522\sdk\build-tools\android-4.2.2

–          **NOTE: use the foldername/path where you installed your bundle**

–          Press OK

–          Press OK again (to close the “Environment Variables” window)

–          Press OK again (to close the “System Properties” window)

–          You can close Control panel window also

–          If you want to check if everything went ok, open command prompt

  • Start menu, in the search programs and files type: cmd
  • It opens “DOS” command prompt
  • Type:> path  (press enter)
  • It should print out your path variable and values (those added bundle paths should be visible there). Note if you go change them now, you need to close “cmd” window and start it again..


 

WINDOWS (continued)

Setup Google USB driver

-          Open file “ *bundle\sdk\extras\google\usb_driver\android_winusb.inf”, with notepad or other text editor

–          Add these 3 lines under: [Google.NTx86] section:
;OUYA Console
%SingleAdbInterface% = USB_Install, USB\VID_2836&PID_0010
%CompositeAdbInterface% = USB_Install, USB\VID_2836&PID_0010&MI_01

–          Add those 3 lines also under: [Google.NTamd64] section:
;OUYA Console
%SingleAdbInterface% = USB_Install, USB\VID_2836&PID_0010
%CompositeAdbInterface% = USB_Install, USB\VID_2836&PID_0010&MI_01

–          Save the text file and close it

–          Then copy&paste this line into (file)explorer window: %USERPROFILE%\.android\adb_usb.ini

–          And press enter, it opens the ini file with notepad

  • Or go to the folder manually: C:\Users\username\.android
  • And open adb_usb.ini with notepad

–          Add this single line to that file: 0x2836

–          So it looks like this now:

–          Save and close it


 

WINDOWS (continued)

Connect OUYA & PC

–          Connect OUYA to your PC with the microUSB cable it came with

–          Turn on OUYA

–          Windows starts to install some drivers.. wait for it to finish

  • For me it finds 2 drivers automatically, last one fails
    USB Composite Device : Ready to use
    OUYA Console : Ready to use
    OUYA : no driver founded
  • It also opens Autoplay, you can browse OUYA files.. close it for now

–          Go to Control Panel / System / Device Manager

–          It opens “Device Manager” window

–          “Other Devices / OUYA” has yellow info sign next to it

–          Right click on it, select Update Driver

  • Then click” Browse my computer for driver software”
  • Then click “Let me pick from a list of device drivers on my computer”
  • Select Show All Devices
  • press next
  • Click “Have Disk”
  • Now browse to your bundle folder (mine was; C:\progs\adt-bundle-windows-x86_64-20130522)
  • Keep going into extras\google\usb_driver\ folder (mine is at C:\progs\adt-bundle-windows-x86-20130522\sdk\extras\google\usb_driver)
  • Once you are inside “usb_driver” folder, there is one file shown there: android_winusb.inf
  • Pick that and press Open
  • Press OK (now at “Install From Disk” window)
  • Now it should show in the Model list: “Android composite ADB Interface”
  • (and a warning on bottom, “this driver is not digitally signed!”)
  • Press Next
  • Installer starts, and Windows security warning pops up
  • Press “Install this driver software anyway”
  • Wait for it to finish, then press close
  • Now autoplay window opens again, close it..
  • Android device is shown in the Device manager, can close that window


 

ANDROID NDK

–          Download ndk from here: http://developer.android.com/tools/sdk/ndk/index.html

  • I took this: android-ndk-r8e-windows-x86_64.zip

–          Unzip it somewhere

  • I placed it next to the sdk bundle at: C:\progs\android-ndk-r8e
  • While copying it from zip file it gave 1 notice about duplicate file (from the zip), I pressed ok to replace..


 

OUYA ODK

–          Download odk from here: https://devs.ouya.tv/developers/odk

  • I got version “1.0.6 – Jun 24, 2013”

–          Unzip it somewhere

  • I placed it next to the other files at: C:\progs\OUYA-ODK

–          **Is this even used by unity?


 

OUYA DEVELOPER ID

–          Sign into: https://devs.ouya.tv/developers

–          Get your developer id from the front page when you are signed in

  • It might first ask you to fill in your details (Developer profile and Marketplace agreement)
  • No need to fill Payment info and tax documents yet..(I read that it takes few months to get all those papers for non-US people..uh)

–          Developer id is there,  “hidden” below those links and above that orange Download ODK button:
Developer UUID (used for configuring in-app purchases):
..xxxxxxx-xxxxxxx-xxxxxxx-xxxxxx-xxxxx..

 

 

 

 


 

UNITY

Example project & Developer ID

–          Let’s use the example projects first

–          Download OUYA Unity project: https://github.com/ouya/ouya-unity-plugin

–          Unzip that folder “ouya-unity-plugin-master”  somewhere where you keep your unity projects

–          Start Unity..finally!

–          Open that project  “ouya-unity-plugin-master

–          “Upgrading project”, click yes (I’m using 4.1.5f)

–          (After few minutes)

–          Unity opens with lots of notices and 2 errors on the console..i’ll just press clear (console) for now..

–          Open scene from: /Ouya/StarterKit/Scenes/SceneInit

–          Select “OuyaGameObject” from scene hierarchy

–          In the inspector, paste your Developer_ID there

–          Then press Apply (to save these settings to the original prefab, so your ID is saved there)


 

UNITY (continued)

Build Settings & Bundle identifiers

–          File / Build settings

–          Switch platform to Android

–          Remove that 1 scene from the “Scenes in build” list

–          Add these scenes to the list:

  • 0: SceneInit
  • 1: SceneSplash
  • 2: SceneMain
  • 3: SceneGame

–          You can set Texture Compression to DTX (Tegra)

–          Then go to Player settings

–          Cross Platform Settings

  • Company Name: (enter some name here)
  • Product Name: (enter some name here) *This is displayed in the Ouya Play list

–          Resolution  & Presentation

  • Default Orientation: Landscape Left

–          Other settings:

  • Type your bundle identifier (com.companyname.productname)
  • Minimum API level: …16

–          Publishing settings:

  • [x] Create new keystore
  • Type some password for the fields

–          Close build settings window

–          Now you need to enter that same your bundle identifier to these 2 places manually:

  • Plugins/Android/AndroidManifest.xml (if you double click this in Unity, it might open it one some text editor, or with monodevelop, otherwise  just explore into that folder and open the xml file for editing
  • There is line: package=”tv.ouya.demo.OuyaUnityApplication”
  • Replace that value with your bundle identifier,
    package=”com.companyname.productname
  • Save and close
  • Next file is “Assets/Plugins/Android/src/OuyaUnityApplication.java
  • Open that with notepad or other text editor (default notepad doesn’t show formatting..looks horrible..use notepad++ or others)
  • In that file there is line: package tv.ouya.demo.OuyaUnityApplication;
  • Replace your bundle identifier there also:
    package com.companyname.productname;
  • Save and close

UNITY (continued)

OUYA Window

–          Select from menu Window/Open OUYA panel

–          Window opens, might show error: “error bundle mismatched”

–          Click the “Sync Bundle ID button” on that window, error should disappear after few seconds

–          Check 3 bundle identifiers are the same

  • Bundle identifier: (your bundle identifier here)
  • App Java Pack: package (your bundle identifier here)
  • Manifest Pack: (your bundle identifier here)

–          Let’s check if everything is ok (if some path is grayed out, it means file was not found = problems)

–          Check UNITY tab, looks ok

–          Select JAVA JDK tab

  • Oh no..everything is grayed out
  • Click “Download JDK6 32-bit”
  • You need to signup for oracle account to download this old version..uh*2
  • Downloaded this: http://download.oracle.com/otn/java/jdk/6u45-b06/jdk-6u45-windows-i586.exe
  • Installed to default folder (but you could specify other folder and then use that from Unity)
  • After its installed, in that Java JDK tab, click “Select SDK Path”
  • Give the folder you installed it
  • Now the paths should not be grayed out anymore

–          Select Android SDK tab

  • Everything is grayed out here also..
  • Click “Select SDK Path” (we had installed the android bundle earlier)
  • Go to that folder, mine was “C:\progs\adt-bundle-windows-x86_64-20130522\sdk”
  • All the paths become ok, except APT Path (it doesn’t find that “aapt.exe”
  • For now we just fix it manually from the code:
  • Open this script from project folder: Ouya/SDK/Editor/OuyaPanel.cs
  • Go to line:  317
  • Duplicate that line and comment out the original:
    //pathAAPT = string.Format(“{0}/{1}/{2}”, pathSDK, REL_ANDROID_PLATFORM_TOOLS, FILE_AAPT_WIN);
  • Then modify the duplicated line to:
    pathAAPT = “C:/progs/adt-bundle-windows-x86_64-20130522/sdk/build-tools/android-4.2.2/aapt.exe”;
  • *Use your drive and folder, go check where that aapt.exe is and make sure your slashes are correct way “/”, not backslashes “\”
  • Save the script and Close, open the Window/Ouya Panel again
  • Now the APT Path line should be ok also

–          Select Android NDK tab

  • Click “Select NDK Path”
  • Give the NDK path (we installed that “android-ndk-r8e”  earlier)
  • Now NDK Path becomes ok
  • Click “Select NDK Make Path”
  • Find the make.exe folder, mine was under “android-ndk-r8e\prebuilt\windows-x86_64\bin”
  • Now that folder is OK also

–          Getting closer..

–          Now back to OUYA tab

–          Click “Compile”

–          Some cmd windows appear and then disappear..not sure whats happening

–          Now let’s close ouya panel

–          Just in case, let’s do also from menu OUYA/Generate OUYA Unity Plugin

–          Connectt OUYA to your pc and start it, if it wasn’t on

UNITY (continued)

Publishing to Device

–          Open SceneInit

–          File / Build & Run      (remember to do the earlier parts, adding the scenes in list etc)

–          It opens the Build settings window..I guess need to give the output path once first

–          Click Build Button

–          Give some folder for the .apk file (put it in your pc, not in the ouya device drives)

–          Let’s name it test.apk

–          Click save

–          (building…)

–          Unity asks for “Select Android SDK root folder” (if you had not given it before in Edit/Preferences/External tools”

–          Give the Android bundle folder, mine was “C:\progs\adt-bundle-windows-x86_64-20130522\sdk”

–          (building…)

–          Done.

–          Put Ouya in the main orange screen (with play, discover, make, manage)

–          Close the build settings window in Unity

–          Let’s do it again, File / Build & Run

–          “Detecting Android device”…”Pushing new content to device..”

–          Ouya screen jumps a bit, let’s go to PLAY menu

–          Our game is now listed on the play menu (yes, it is that icon with horrible mess & colors)

–          Let’s try to run it

  • Yay! We got 2 unity default GUI buttons, which we cannot even press..(maybe if plugin a mouse we could?)
  • But now we can start building some game on that scene then..

9 Comments + Add Comment

  • I had a better time using https://github.com/getluky/OuyaUnityBridge

    Input is more similar to how Unity handles it natively

  • Thank you. What a god damned mess. I expect the Ouya team will work to make this less of a fucking nightmare in the future.

    But for now, this is the only tutorial that has made the slightest bit of sense (including the “twelve steps missing from every step” official youtube instructions)….

    So I must thank you deeply for your work, mgear! You’ve helped me out infinitely.

  • Well done on the guide. I had started one myself back in ODK v0.0.4, but it was just such a bloody mess…

    Since ~January I’ve had a slew of issues with JDK, NDK, bundle ids mismatching, ODK itself releasing with major bugs (not unit tested?), etc.

    +1 to hoping they get some of this cleaned up in the future!

  • Thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you.

  • TitleSafeAreaDisplay (helps debug games for TVs (i.e. Ouya or other console) by rendering the title safe area guides on top of the scene)
    http://wiki.unity3d.com/index.php/TitleSafeAreaDisplay

  • Yeah, this was mega helpful. I’m not sure why they don’t have beginning to end setup instructions on the actual Ouya unity page…

  • Awesome instructions, but the apk won’t launch on the Ouya for me. I’ve tried a few different tutorials and none of them work. The apk installs fine and I see the name/icon on the play list. When I select it, it goes to a black screen, and then back to the menu. Am I doing something wrong or did the latest update change something so none of these Unity tutorials work?

    • Havent tried the new packages or after ouya updates if this still works..

      I had that blackscreen few times also. I think it was something with the scenes,
      either wrong id, didnt have them in correct order, or missing some other ouya scene components..

Leave a comment

Connect

Twitter View LinkedIn profile Youtube Youtube Join Discord Twitch

UnityLauncherPro

Get UnityLauncherPRO and work faster with Unity Projects!
*free unity hub alternative

@unitycoder_com

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.