有时候unity调android aar时需要传入Context参数,此时需要在android的ui线程运行
public void Login(string account,string password)
{
Debug.Log("Func_Login");
AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject jo = jc.GetStatic<AndroidJavaObject>("currentActivity");
AndroidJavaObject context = jo.Call<AndroidJavaObject>("getApplicationContext");
jo.Call("runOnUiThread", new AndroidJavaRunnable(
() =>
{
jo.Call("Login", context, account, password);
}));
}