尝试使用“ UnityPlayer.UnitySendMessage”在Android Studio中选择不同的Unity场景。 (未加载本机库错误)

问题描述 投票:-1回答:1

我从Unity导出了多个Unity场景,这些场景已作为库导入到Android Studio中。我的目标是在Android Studio中设置一些按钮,单击这些按钮将从Unity项目中加载特定场景。我正在关注this教程,并且已将C清晰代码添加到我的每个统一场景中,但无法使UnityPlayer.UnitySendMessage部分起作用。

这是我的MainActivty.java,其中包含UnityPlayer.UnitySendMessage。

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import com.unity3d.player.UnityPlayer;
public class MainActivity extends AppCompatActivity {
    boolean isUnityLoaded = false;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    public void btnLoadUnity(View v) {

        UnityPlayer.UnitySendMessage("SceneLoader", "LoadScene", "One");

        isUnityLoaded = true;
        Intent intent = new Intent(this, MainUnityActivity.class);
        startActivityForResult(intent, 1);
    }

    public void btnLoadUnity2(View v) {
        isUnityLoaded = true;

        Intent intent = new Intent(this, MainUnityActivity.class);

        startActivityForResult(intent, 1);
        UnityPlayer.UnitySendMessage("SceneLoader", "LoadScene", "Two");

    }
}

意图调用了第二个活动,该活动启动了统一活动:

import android.content.Intent;
import android.util.Log;

import com.unity3d.player.UnityPlayer;
import com.unity3d.player.UnityPlayerActivity;

public class MainUnityActivity extends UnityPlayerActivity {
    //@Override
    protected void showMainActivity(String setToColor) {

        Intent intent = new Intent(this, UnityPlayerActivity.class);

        startActivity(intent);

我在日志猫中收到未加载本机库-删除SceneLoader.LoadScene的消息错误。

java c# android unity3d
1个回答
0
投票

嘿,我遇到了同样的问题。您设法解决了吗?

© www.soinside.com 2019 - 2024. All rights reserved.