How to integrate Unity into Android activity

This is my first time using Unity, and I want to integrate it into an existing Android application.

From what I read, you need to pack your Android project into a jar file. Since you cannot include the resource folder in the bank, how do I handle all the resources for my application? The application also uses the ActionBarSherlock and ViewPagerIndicator libraries, which also have their own resources.

I just need a way to click on the button on Android and open the "Activity" containing the Unity stuff. I want the rest of the application to be native Android code. Thanks for the help!

+7
source share
2 answers

I get it. I followed these directions , but continued to receive various error messages, including ClassNotFound exceptions.

It turns out that the way ADT 17 processes .jar files violates this Unity integration method in Eclipse. After hours of searching, here I came up with a fix:

Instead of adding class.jar to your build path, you should just copy the classes.jar file to the /lib directory of your project, and everything should work as expected.

+6
source

Hi Below are the steps to follow

  1. Create a unity project with Android Pro.

    1. Open unity. go to File-> build settings in Unity and create a build for the project.
    2. go to your project location / temp /.
    3. There is a folder called Staging area.
    4. Copy this folder to another location. rename this folder. for example, test unity.
    5. Now go to eclipse to create a new project from existing code. go to test-unity and select it. A new project has been created.
    6. Right-click on the project and select properties.
    7. select Android from the list of left tabs. and check this library in the right pane. apply changes.
    8. Now create a new project in Android and name it test-android.
    9. The package name should be the same as you used in Unity.
    10. Right click on the project. go to android and add the library. You will see the name of the unity project. select it. Unity project added as a library in Android test project.
    11. Now copy the asset folder from the Unity project to Eclipse to test the Android project.
    12. Also copy libs-> armeabi-v7a to the libs folder in unity.
    13. Now go on to setting unity dir. In my case (C: \ Program Files (x86) \ Unity \ Editor \ Data \ PlaybackEngines \ androiddevelopmentplayer \ bin). Copy classes.jar to the libs folder in the test-android project. optional-. If after copying the classes.jar file in the android-dependencies folder of the android test project you do not see classes.jar, go to the test-android assembly and include this jar file.
    14. Now open the main Activity.class file in the test-android project and paste this line

    import com.unity3d.player.UnityPlayerActivity;

    1. Now replace Activity with UnityPlayerActivity as shown below

    public class MainActivity extends UnityPlayerActivity

    1. comment out the line setContentview (R.layout.main).
    2. Now run your application.
+1
source

All Articles