I made it by following steps: Integrating Unity and Eclipse. Can I call functions (that I created with JavaScript or C# in Unity) with the Android SDK or NDK and the other way around? There are an interface between UnityPlayer and Android SDK or NDK?
For whom this may help:
As @Oli mentioned, you can communicate between Unity and an Android app by using this method:
UnityPlayer.UnitySendMessage("GameObjectName1", "MethodName1", "Message to send");
In order for this method to work, you must follow this guide: http://forum.unity3d.com/threads/71607-Integrating-Unity-and-Eclipse
You can also call Java methods from Unity C# file - http://docs.unity3d.com/Documentation/Manual/Plugins.html
You can use this code in order to start the Unity app after you add it as library to your Android project:
UnityPlayer mPlayer = new UnityPlayer(this); // Put your activity object here
int glesMode = mPlayer.getSettings().getInt("gles_mode", 1);
boolean trueColor8888 = false;
mPlayer.init(glesMode, trueColor8888);
Hope this helps anyone... I've researched a lot until I found this information.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With