ios - 使用 iOS 版 GoogleVR (GoogleCardboard) 在 Unity 中创建单一 View

标签 ios unity-game-engine google-cardboard google-vr-sdk

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

虽然这可能与 VR 的理念相矛盾,但我实际上只想要一个中央摄像机的视角,并让该显示填充整个屏幕。

我一直在搜索 Unity 项目文件和 google Cardboard 文件,但尚未找到实现此目的的方法。有没有一种简单的方法可以关闭两眼显示并改为进行单 View ?如果是这样,我要修改什么文件?

谢谢!

最佳答案

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 的脚本)。

关于ios - 使用 iOS 版 GoogleVR (GoogleCardboard) 在 Unity 中创建单一 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54847760/

相关文章:

android - UNITY 3D 的磁铁脚本

iOS - UIViewController - 覆盖 UIViewController 子类链中的 getter 时出现运行时错误

ios - Swift - 如何检查现有的 Core Data Store iOS

c# - GPS 时间戳帮助。 unity3d中安卓设备同步失败

ios - Unity iOS 背景音频变得静音

ios - iOS像Homido App一样并排播放同一视频

ios - uinavigationbar uiappearance in popover bartintcolor 不工作

ios - 在 UIView 中拖动 UILabel 并维护其新坐标

c# - 如果无法选择 Mysql,则可以选择 Mysql 数据库替代方案

ios - 如何使用 Google Cardboard SDK 在 Unity 中为 iOS 构建 VR 视频播放器