top of page
Search

Unity3D to Wear OS Tutorial - Part 1

Updated: Apr 1, 2023

"The world of mobile devices is expanding..." Want to see a game created with this process? Check out 'Combat Wear' on google play.

Looking to support upcoming games? Check out our newest game Chronomon on Kickstarter! A monster taming JRPG for WearOS smartwatches/Steam crossplay Even a follow on Kickstarter would mean so much as a thanks for making this tutorial =)





Like or comment on this and let us know if you want a full tutorial from start to publish. Check out the Games we have created including the latest release... the 2nd Combat Wear!

- Unity - Although Unity does not support Android Wear the process of porting a Unity Game over is relatively simple. The beauty of it all is that Android phones and watches use the same file (.APK). The process for Apples watches is probably different but ill cover that in another post. Let's start from the beginning. Your Unity project needs to be compiled correctly. First make sure your project build settings platform is set to Android by going to (File - Build Settings - Click on Android - Switch Platform) then the build system needs to be set to (Gradle) and the box (Export Project) needs to be clicked.


After completed navigate over to (Edit - Project Settings - Player) There are a couple fields you will want to modify here. Some of these you can do within android studio but may as well knock them out now. First be sure to set your company name and product name (company being obviously what you want your company name and Product name to be the name of your application on Google Play) From there click the drop down menu (Other settings) and under Identification set your bundle identifier to 'com.companyname.productname' then set your Minimum API Level to API level 23 (the minimum for running android wear 1.0). If you are creating a 2.0 app, we can change that later.


Everything your setting in here can be changed from Android Studio. If you want to update your Icon or anything else go for it but not necessary now. This just sets up the Android Manifest and gradle as your importing it.


Be sure to Set your SDK and JDK in Unity Preferences (Edit - Preferences - External Tools) or you won't be able to export the project. After all is set, head back over to your build settings and click (Export). This will build the Android Studio package. - Android Studio - Now I have seen multiple ways of doing this, there are a few tutorials out there that say different things but were going to go in depth and use a couple of their methods combined. Open Android Studio and create a new Project.


Set your Application and company name. The Package name should match the name you set in Unity earlier on. (com.companyname.appname) If you wish to edit it directly just click on the edit button on the right hand side. (Click Next).


Here we will be configuring what devices we will target. This will change depending on if you want to target Android 2.0 (Standalone Apps) or if you wish to target Android 1.0+. Here I am going for the biggest audience so make sure (Phone and Tablet) is selected and I have API 19 selected. 'this will target a majority of devices and still keep functionality'. Click (Wear) and target the minimum API to be 23. It works with lower versions but Android documentation says to do this. Click (Next).




This sets up your project layout. Click (Empty Activity) for mobile and hit (Next). I like to name my activities based on the type of device to avoid confusion but you can leave the activity name alone if you want. Click (Next). Click (Blank Wear Activity) then (Next). Do the same for the watch activity name and Click (Finish). Your application should start the Gradle build process. Let it finish and we will continue.

Now we import the Gradle build that Unity created for us. Click (File - New - Import Module) Find the Unity Export and click (Finish). Allow the Gradle to finish syncing and chances are that you will need to download some SDK tools. Android Studio will pop up a message letting you know if you need anything.

So Now we have our Unity Project imported, what now? This is where the real work comes in. On the left hand side, open up your (Project) menu. We are going to start dissecting the module we imported and piecing together our individual apps. First off, Copy/Paste the unity-classes.jar file into the wear app. Now Copy/Paste from your imported module the entire assets folder and jniLibs (Module - src - main - assets and jniLibs) into the main folder under your wear app. (wear - src - main) . Leave the names the way they are. Also, Copy/Paste the module activity (src - main - java - packageName - UnityPlayerActivity) into the wear app section. (src - main - java - packageName).


Errors will happen! Don't be alarmed! The UnityPlayerClass we just copy/pasted should be throwing up some red flags (Perhaps a couple more, I will cover all of the ones I run into). Head over to the wear Gradle File (wear - build.gradle) and add this to the dependency section.

I wont lie to you and say I'm an Expert at Android programming, line 26 is just needed to removed errors on my line 23 and I'm not entirely sure what it's for (something about run-time code). That's ok though right? Were Unity programmers after all. Line 26, compile files ('libs/unity-classes.jar , will include all of the unity files necessary to run your game through android studio and create the build. After re-syncing the Gradle, head over to the UnityPlayerActivity (wear - main - src - java - packagename - UnityPlayerActivity) and add an import at the top of the class below the rest of the imports.

This should fix all of the issues with that. On to the next thing! Go to your wear section and open the AndroidManifest.xml. You will need to set your launcher activity to our new UnityActivityPlayer. Were almost there!



If this has been helpful and you want to support further smartwatch gaming development and information. Please follow me on Ko-Fi or support there. Any help goes a long way to making more informed, updated tutorial and better games. Thanks for reading!


Go ahead and test your game! If you haven't configured your virtual devices you'll need to do that. There should be plenty of tutorials on how to do this. A couple things you may notice is

  • The orientation may be going crazy.

  • If you are building on a Round watch, the image may be off the screen or construed.

There is more to the process if you wish to release the game on Google Play or fix any of the above problems. If you wish to know more, leave a comment or email us! If this was helpful, give Combat Wear 1, 2, or Scrap Wars a try! Combat Wear on Google Play

Please like and share Stone Golem Studios on Facebook so we can continue bringing you more smartwatch games!


5,034 views4 comments

Recent Posts

See All

4 Comments


Aco Van Conis
Aco Van Conis
Aug 23, 2023

That blog post is awesome, thank you

Like

Rebeca Paducon
Rebeca Paducon
Jul 11, 2023

unity 3d is better than other. Should I use URP for 2D Unity?


Thanks from apkohi😌

Like
Nicholas Gorman
Nicholas Gorman
Jul 11, 2023
Replying to

Yes, URP is considered standard now. =}

Like

action reviewer 31
action reviewer 31
Dec 26, 2021

thanks for this, theres barely any other documentation online.

Like
bottom of page