Hey guys
So i already built a plugin that is a receiver and receives a messagem from android, i can communicate Android → Unity
But know i want to do the other way around, basically i want everytime a spider spawns in my game i will send a simple string like “Spider” to android.
Any help?
my way:
UNITY:
public static void CallAndroidMethod(string methodName, string str)
{
using (var clsUnityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
{
using (var objActivity = clsUnityPlayer.GetStatic<AndroidJavaObject>("currentActivity"))
{
objActivity.Call(methodName, str);
}
}
}
public static void sendStr(string str)
{
#if !UNITY_EDITOR
#if UNITY_ANDROID
CallAndroidMethod("receiveStr", str);
#endif
#endif
}
ANDROID:
public void receiveStr(String str)
{//
}
2 Likes
Is there a similar version of this for Swift and iOS at all? Thanks