Skip to content
A simple example of an Android specific plugin for Unity3d
C# Java
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
AndroidPlugin Fixed issue with previous commit Sep 19, 2015
UnityProject Updated README and documentation in code Oct 16, 2015
.gitignore Added AndroidPlugin to repo. Sep 15, 2015
LICENSE Initial commit Sep 7, 2015
README.md Updated README and documentation in code Oct 16, 2015

README.md

Unity-Android-Plugin-Example

A simple example showing how to call native Android Java code from Unity. http://www.what-could-possibly-go-wrong.com/creating-a-native-android-plugin-for-unity3d/

The UnityProject directory contains the Unity project (set up with Unity 5.2), with everything you need to build it for Android.

The AndroidPlugin directory contains the source to the native Android plugin used in the Unity project (AndroidPlugin.jar), which has been tested against Android 5.0 (API level 21).

Building

To build the Unity project, just open it in Unity, connect an Android device and go to Build and Run in the menu. There is already a compiled version of the Android plugin (AndroidPlugin.jar) in the Unity project Assets folder so there is no need to compile it first just to run the program.

To build the Android plugin, first make sure you have installed the Android SDK and Ant. First, either make sure your ANDROID_HOME environment variable is set to your installation of the Android SDK, or edit the sdk.dir=... line in the local.properties file inside the AndroidPlugin folder.

Once that is all configured, navigate to AndroidPlugin and run

ant jar

Then copy the compiled AndroidPlugin.jar from AndroidPlugin/bin to UnityProject/Assets.

You can’t perform that action at this time.