Tuesday 26 May 2015

Unity3d to Android Wear!

Ok so finally i have been successful in porting a Unity3d project to a Moto 360!

Step 1: Export the Unity project as a Google Android Project make sure you set your bundle id
e.g. co.uk.mycompany.test 

for the Minimum API Level select Android 4.4 'Kit Kat' (API Level 19)


Step 2: Create a new blank project on Android Studio. (Android Studio -> File -> New -> New Project). Make sure when you fill out the form above the package name is the same as the one you entered in Unity (co.uk.mycompany.test) once that is all set click on Next.


Step 3a: Select the same Minimum API Level and make sure you tick the Wear box! and select the minimum API Level  (Android 4.4 'Kit Kat') then click next


Step 3b: Leave it as it is and press next.




Step 3c: Leave it as it is and press Finish and let the project set itself up.


Step 3d: Then change the view set up to Project.


Step 4: Time to import our Unity Project. File -> New -> Import Module... then choose the directory where you saved the Unity Project in Step 1 then press Next followed by Finish and let the project set itself up.

Step 5: Once it is set up you need to Delete the MainActivity.java file from the wear folder. 
wear -> src -> main -> java -> co.uk.mycompany.test -> MainActivity


Step 6: Copy the unity-classes.jar from the module you imported it will be in 
test -> libs -> unity-classes.jar and paste this into the lib folder for the wear module (wear -> libs ->...)


Step 7: Copy the assets, java, jniLibs folders from the imported Module test -> src -> main -> and paste them into the main folder for the wear module wear -> src -> main -> ... 

If everything is done correctly you should be able to deploy this onto a device or emulator. I will be posting about how to run a game straight onto an android watch in my next post :).

If you want to make any changes to your unity project and then make it wear friendly all you have to do is start from Step 4. But i would suggest deleting the test module first.

I would like to credit technidus but had to amend a few things to make it work fully!

3 comments:

CP-Tech said...

Either I did something wrong or this process also requires copying some manifest files over as described in this doc http://technidus.com/tutorial-creating-build-in-android-studio-from-unity-project/ Is this right? Also, did you find a way to fix the orientation no matter what model the watch is (G watch, Moto, etc.)?

Abz A1 said...

Which lines from the manifest did you copy over? i will have a look a little later today at what my manifest looks like.

Unfortunately i only have a Moto 360 so haven't been able to test it on other devices, have you got any devices that you have tested it on?

Johan said...

I wrote a tutorial and added example projects to it.
http://pastille.se/2016/12/13/make-unity-games-run-android-wear/ Hope this helps