使用适用于iOS的GoogleVR(GoogleCardboard)在Unity中创建单一视图

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

我是一名大学生,尝试使用Unity与GoogleVR sdk(Google Cardboard)配对,为iOS构建VR应用程序。我可以让我的应用程序在iPad上运行,但屏幕上的显示是通过两个视口(或相机,不确定正确的术语)为两只眼睛。

虽然这可能与VR的想法相矛盾,但实际上我只想要一个中央相机的视角,并且该显示器可以填满整个屏幕。

我一直在搜索Unity项目文件和谷歌Cardboard文件,但还没有找到办法。是否有一种简单的方法来关闭双眼显示器而不是单个视图?如果是这样,我会修改哪个文件?

谢谢!

ios unity3d google-cardboard google-vr-sdk
1个回答
0
投票

Cardboard SDK在iOS上为您提供的主要功能是立体渲染,基于陀螺仪控制相机旋转以及凝视指针。如果您不想要立体渲染,可以在XR设置中禁用VR支持,并对其他两个项目使用一些简单的替换。您可以在场景中添加常规相机,然后使用这样的脚本根据手机的陀螺仪设置旋转:

using UnityEngine;

class SceneManager : MonoBehaviour {

    void Start() {

        // Enable the gyro so that it can be used to control the camera rotation.
        Input.gyro.enabled = true;
    }

    void Update() {

        // Update the camera rotation based on the gyroscope.
        Camera.main.transform.Rotate(
            -Input.gyro.rotationRateUnbiased.x,
            -Input.gyro.rotationRateUnbiased.y,
            Input.gyro.rotationRateUnbiased.z
        );
    }
}

要替换凝视指针,您可以使用Unity的独立输入模块通过输入系统路由屏幕触摸事件(例如,触发实现IPointerClickHandler的脚本)。

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