Unity and Android Studio Integration

To Set up an Android project for a Unity project is really simple.

Unity

  1. Goto File -> Build Settings -> Android and click Switch Platform
  2. Enable Google Android Project
  3. Click Export and choose where you want the Android project to be

UnityAndroidSource

The Export will produce a structure similar to this:

UnityAndroidSourceFolder

Android Studio

  1. Import the project you have just created with Unity in the way you would use for Eclipse Projects.
  2. Done ūüôā

This doesn’t mean that you can develop a Unity App Project in Android Studio. The development of the (mostly) game has to be done in Unity.

If you only want to make an APK from a Unity project you don’t need Android Studio in most cases. Just use the Build Settings from Unity and this time, disable¬†Google Android Project. The button <Export> will change into <Build>. The click on <Build> will pack an Android APK that can be uploaded to your phone.

UnityAPK

To export the Unity Source Code and import it into Android Studio could be interesting to add certain type of Ads or build Cardboard (Virtual Reality) Apps.

A good starting point for Android – Unity Developer is the Android Section in the Unity-Manual.

TIP:

To force the Unity game into landscape mode, you have to make the configuration in Unity NOT in Android Studio.

This is what you do:

Open again the Build Settings Menu and click on Player Settings.

PayerSettings

The Player Settings button opens the Inspector Window.

landscapemomde

Go to Resolution and Presentation and choose one of the Landscape Modes (green arrows).

The configuration made here in Unity will then make the right entry in the AndroidManifest.xml, like this:

android:screenOrientation="reverseLandscape"

Now, go ahead and export the project from Unity like before and import it into Android Studio.

Here we go.

device-2015-08-22-125007

If you want to see how the Android Studio Project looks like for this example, download it from here.

A project like this is made in a day when you start from scratch. And you can be even faster by using one of the templates the Unity Asset Store offers.

 Our New Game for Android

read more and win the full Source Code.

 

 

 

Category: Uncategorized
Tags: