我阅读了“更多Google OBB戏剧”主题,并看到了这样的消息:“在主要活动的暂停/恢复周期中,将OBB添加到了“搜索路径”。Application.dataPath将指示它是否已安装。
因此,如果未安装,则需要触发一个暂停/恢复周期(最简单的方法是从eriQue初始化一个“虚拟”活动,该活动仅立即返回。)所以我尝试这样做,但我认为我做错了,原因我对Java和Android开发(活动)非常讨厌,这是我的代码:

public class ReloadObbActivity extends Activity {

private Intent myIntent;


@Override
protected void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    myIntent= new Intent(this,ReloadObbActivity.class);
    finish();
}

public void Launch()
{
    startActivity(myIntent);
}


}

 public static void RunDummyActivity()
{
    using (AndroidJavaClass unity_player = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
    {

        var jc = new AndroidJavaClass("mycompany.com.reloadobbplugin.ReloadObbActivity");
        jc.Call("Launch");



        if (AndroidJNI.ExceptionOccurred() != System.IntPtr.Zero)
        {
            Debug.LogError("Exception occurred while attempting to start DownloaderActivity - is the AndroidManifest.xml incorrect?");
            AndroidJNI.ExceptionDescribe();
            AndroidJNI.ExceptionClear();
        }
    }
}


因此它不起作用,也没有例外

最佳答案

我知道我错了。

public class DummyActivity extends Activity
{
  protected void onCreate(Bundle savedInstanceState)
  {
    super.onCreate(savedInstanceState);
    finish();
  }

  public static void Launch(Activity activity)
  {
    Intent myIntent = new Intent(activity, DummyActivity.class);
    activity.startActivity(myIntent);
  }
}


和C#代码:

public static void RunDummyActivity()
        {
            using (AndroidJavaClass unity_player = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
            {
                AndroidJavaObject current_activity = unity_player.GetStatic<AndroidJavaObject>("currentActivity");

                var jc = new AndroidJavaClass("com.exampleCompany.DummyActivity");
                jc.CallStatic("Launch", current_activity);
            }
        }


将Java代码导出到jar文件并将其放置在Plugins / Android中。
并且不要忘记在此活动中添加行以显示。

10-07 20:01