使用Scenform将SceneView加载到片段中后的黑屏 [英] Black screen after loading SceneView, using Scenform, into a fragment

查看:111
本文介绍了使用Scenform将SceneView加载到片段中后的黑屏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在一个项目中,该项目将在一个片段中包含3D模型查看器.为了做到这一点,我决定使用sceneform.尝试显示后,我在选项卡片段中遇到了SceneView问题.

I am working on a project that will have a 3D model viewer in one fragment. In order to do so, I decided to use sceneform. I have encountered a problem with SceneView, after trying to display it, in my tab fragment.

一切都根据示例和场景形式文档完成,但是 sceneView 显示黑屏,而不管我分配的颜色是什么.

Everything is done according to examples and sceneform documentation, but sceneView display black screen, regardless of the colour I am assigning.

这是场景加载器

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        vw = inflater.inflate(R.layout.fragment_open_gl, container, false);
        sceneView = vw.findViewById(R.id.scene_view);
        return vw;
    }

还有片段:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".OpenGL">

    <com.google.ar.sceneform.SceneView
        android:id="@+id/scene_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/Crimson"/>

</FrameLayout>

推荐答案

我通过添加暂停和恢复场景视图以及片段来解决了该问题:

I solved the issue by adding pausing and resuming sceneview, along with the fragment:

    @Override
    public void onPause() {
        super.onPause();
        sceneView.pause();
    }

    @Override
    public void onResume() {
        super.onResume();
        try {
            sceneView.resume();
        } catch (CameraNotAvailableException e) {
            e.printStackTrace();
        }
    }

这篇关于使用Scenform将SceneView加载到片段中后的黑屏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆