Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Integrating Unity with Eclipse - Communication?

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?

like image 412
Oli Avatar asked Feb 06 '12 12:02

Oli


1 Answers

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.

like image 62
Lior Iluz Avatar answered Sep 24 '22 19:09

Lior Iluz