Created
February 20, 2020 06:10
-
-
Save rkandas/ababd3004d300edd9bf3b9c35014cb18 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEngine.UI; | |
public class DataExchanger : MonoBehaviour | |
{ | |
public InputField fld; | |
// a method which can be called from Android app | |
public void ShowMessage(string message) | |
{ | |
fld.text = message; | |
} | |
public void PassDataToAndroid() | |
{ | |
AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); | |
AndroidJavaObject activity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity"); | |
activity.CallStatic("setDataFromUnity", new object[] {fld.text}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment