Unity作为Android子活动黑屏

时间:2018-02-27 12:20:19

标签: android unity3d

我正在尝试将Unity场景显示为Android中的子活动(已导入到Android Studio的项目)。

现在,当它在framelayout中加载场景时,它只是保持黑屏。我没有发现任何错误,并且它似乎在Debug或Logcat上都不为空。

https://imgur.com/uForG1Y

以下是我现在正在使用的代码:

public class MainActivity extends Activity {


    private UnityPlayer m_UnityPlayer;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // Create the UnityPlayer
        m_UnityPlayer = new UnityPlayer(this);
        int glesMode = m_UnityPlayer.getSettings().getInt("gles_mode", 1);
        boolean trueColor8888 = false;
        m_UnityPlayer.init(glesMode, trueColor8888);

        setContentView(R.layout.activity_main);

        // Add the Unity view
        FrameLayout layout = (FrameLayout) findViewById(R.id.frame);
        FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
        layout.addView(m_UnityPlayer, 0, lp);
        m_UnityPlayer.requestFocus();
    }

我一直在检查一些文档和答案,但没有什么对我有用

Unity scene a as SubView

Unity and Android: Create an Unity app with a custom layout

Unity scene as a SubView by tnetennba

任何帮助将不胜感激,谢谢!

0 个答案:

没有答案