unity向android通信

//创建android对象UnityPlayer
AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
//unityPlayer通过GetStatic("currentActiviy")获取UnityPlayer中静态变量currentActivity,该静态变量保存的是当前activity对象
AndroidJavaObject activity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
//调用当前activiy对象的静态方法AwesomeFunction,并将当前activity对象传入
activity.CallStatic ("AwesomeFunction", activity);

 

你可能感兴趣的:(android)