Porting a Unity 3D app to the wearable platform is quite straightforward, even if not yet fully supported by the Unity IDE itself.
It’s always interesting to see a new platform evolve, especially at the speed that wearables do…
Smartwatches have come a long way in a very short time – from a quite ‘dumb’ external LCD display to what is basically (in some cases literally) a second phone on your wrist.
And those little devices have become quite beefy too – they feature (last-)generation smartphone specs (and don’t have to push half as many pixels as other mobile devices).
This screams for 3D and thus Unity – so I got hold of a LG G Watch to try and bring Orrery to Android Wear.
The LG G features a Snapdragon 400 (quad core A7 cortex @ 1,2 GHz), 512MB RAM and 5GB flash – it shares those specs with Samsung’s Gear Live – the only other Android Wear watch that is available right now…
Marty McFly: “Whoa Doc, do you mean to tell me this sucker is nuclear?”
Dr. Emmett Brown: No, no, no, no, no, this sucker’s electrical.”
Killing the darlings
A smartwatch is not so smart when it comes to handling user input – the limited number of buttons (exactly zero in case of Android Wear) and the tiny touch screen make complex interfaces next to impossible.
The first thing I did was to strip a lot of functionality from the original app.
Navigating a 3D viewport with your thump, while it obscures the whole screen, is also a hopeless endeavour – so I removed the camera control and set it to fly on an automated curse. It is now trailing a randomized bezier curve through our solar system.
In the end, the whole GUI was deactivated in favor of just one action: double tap to exit…
Sound was also removed, texture sizes halved and antialiasing deactivated – it doesn’t really make that much of a difference on those screen sizes anyway.
So it’s basically Orrery light – on auto pilot.
From Unity to Android Studio
Now I have a working android app that should behave quite well on a smartwatch – but how to install it there?
Since Android Wear is well… Android, we can just compile with Unity as usual and side-load the *.APK to the device.
Works like a charm – in fact, I even installed the original release and ran it without issues.
But this won’t fly on the Play Store, a real wear app looks a bit different – it exists of two parts:
The phone-module, and the wear-module.
The first is supposed to run as a service and- or front end on the users mobile – the second on the wearable device itself.
While smartwatches are quite powerful, they are very limited by their battery run-time, so offloading networking and some of the heavy lifting to the phone is a good idea.
Orrery doesn’t benefit from any of this, but it still has to ride piggyback on a “phone” type app.
So I exported it as a Google project from Unity and installed Android Studio.
Packaging and Publishing
The following part just reiterates parts of Googles documentation – please have a look at it here:
The project was imported as “OrreryWear” and a clean Android application “OrreryWearPhone” added.
Package name, version numbers and permissions in the ‘build.gradle’ and ‘AndroidManifest.xml’ files of both applications have to be identical – I also added the line
<uses-feature android:name="android.hardware.type.watch" /> to the wear app’s manifest and copied the icon-drawables over.
The phone module gets compiled with the SDK version 9, the wearable with 20 (KitKat Wear).
Finally, the wearable module is added as a dependency to the phone app:
The last step is to add the existing release key from the Unity project and compile the *.APK.
A small issue when testing the build, was the fact, that Orrery is quite large (23MB) and took over a minute till it got transferred to the watch via BlueTooth. I guess most Unity applications will be a bit heavy on file size by nature, so you (and your users) have to be patient…
I still decided against having a phone front end, with nothing more than an info message like “please wait till this app got transferred to your watch”.
Yes, it would ‘solve’ the issue via user education which is admittedly better than nothing, but the user ends up with all those shortcuts to what are essentially dummy-apps – not ideal either.
I think this is something Google has to solve in future iterations of Android Wear (for example by just adding another installation-process notification for the wear module).
Another interesting issue is the device orientation. While this is normally a no-brainer, it seems to get a bit fuzzy with smartwatches.
I was made aware that Orrery renders 90° rotated on Motorola’s Moto 360 watch. Well… I had to chose portrait in Unity’s settings to have it oriented correctly on the LG G, but it looks like the Moto 360 needs the landscape setting.
I feel like this shouldn’t happen, granted I’m not sure if “up” is such a clear defined concept with watches who have square screens (relative to the straps I would assume) – but still this feels like a bug.
Oh, and one last thing – be sure not to use auto-orientation, a watch is seldom held level.