Unity中调用Java方法

作者:追风剑情 发布于:2015-2-3 11:42 分类:Unity3d

AndroidJavaClass player = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
//返回当前活动对象
AndroidJavaObject curActivity = player.GetStatic<AndroidJavaObject>("currentActivity");

//调用实例方法
curActivity.Call( "方法名", 参数,... );
//调用静态方法
curActivity.CallStatic( "方法名", 参数,... );

//使被调用的java方法在主线程中运行
curActivity.Call("runOnUiThread", new AndroidJavaRunnable(() =>
{
	curActivity.Call( "方法名", 参数,... );
    curActivity.CallStatic( "方法名", 参数,... );
}));

标签: Unity3d

Powered by emlog  蜀ICP备18021003号-1   sitemap

川公网安备 51019002001593号