Ouya Unity Plugin for Newer Unity Versions

Hello devs, upon finding out that to use rewired input for Ouya I needed the ouya unity plugin, I had no other choice (I probably did) but to get the plugin working on the most recent version of unity that can build to Ouya. This version happens to be Unity 2019.2.21f1.

As some of you have noticed, the Ouya unity plugin makes the game crash as soon as you open it. Through some debugging with log cat, I was able to track down the moment the game crashes which is in the custom Activity inside OuyaUnityPlugin.jar(Assets/Plugins/Android/libs). To be honest I’m no java expert or have experience with native android code, but I was able to figure out from the unity docs that the way to create a custom entry Activity looks different from how the Ouya team did it(they create a new script that extends Activity, docs say to extend the included UnityPlayerActivity. Also I feel like it could be that unity changed their namespace in newer versions, I don’t really know).

Knowing this and after a couple attempts I finally arrived at the solution of creating a new Android Studio project and adding all the scripts from the plugin’s source code(thanks goodness the java source code is available on Ouya’s github) and modifying the MainActivity.java file to extend UnityPlayerActivity and removed some code that UnityPlayerActivity takes care of. Along the way I kept getting lots of errors from TurretMouseService.java about it using methods that require minimum api to be higher than level 16, so I messed with some of that code and Razer Turret Mouse might not work as expected. I was able to build the OuyaUnityPlugin.aar and replace the old jar file and… IT WORKED! My Ouya launched the game just fine.

The package for the updated plugin can be found here, and the source code that was forked from the ouya repo can be found here which includes that Android Studio Project. I’ve also removed some examples that had missing scripts and I updated some links on the OUYA Panel. There is an error that shows up in the console when opening the OUYA Panel but it can be dismissed and it shouldn’t keep you from building your game. All you need to do is go to the Player tab in Project Settings, add OpenGLES2 to the Graphics APIs list, change the Minimum API level to 16 and you are set to build your game to Ouya!

There are some features I’m planning to add to the plugin, like adding a custom Scripting Define Symbol to avoid typing the long #if UNITY_ANDROID && !UNITY_EDITOR all the time (and I think some people might want to still build to regular android without including Ouya code in their build), but this is good for now. Hope to see some more games on Discover soon!

5 Likes

Wanted to say thanks for this!
I was stuck trying to backport many games for OUYA to Unity 4 or Unity 5.6.7, in order for them to build with the old OUYA ODK plugin, but now, thanks to your updated OUYA ODK plugin, I can use from Unity 4, 5, 2017, 2018, 2019 up to 2019.2.2 (I thought last version of Unity to support API 16 was Unity 2019.1).
This adds more possibilities to use newer Unity assets and game kits on the OUYA!
Thanks again!
Elijah

1 Like

That’s awesome. More great stuff from @sketche99 in the pipeline.

Should Goest remove these repos for any reason in the future, I have also forked them: