我正在使用unity (版本2019.1.1)构建Android/IOS应用程序,我打开了一个3D项目,虽然项目中的所有场景都是2D的,但视频播放器应该有两种模式VR和360显示
所以我只需要一个场景的VR支持(这是视频播放器,目前使用google-vr-sdk构建)。其余的场景是2D的,不需要启用VR。
然而,如果我选择不启用VR设置(XR设置),360视频不会通过运动传感器移动,但应用程序的其余部分工作正常。如果我启用了VR设置,我根本看不到主屏幕。
我目前的工作是开发两个应用程序,一个只包含视频,另一个应用程序具有其余功能。但我不知道如何将它们联系起来。我想知道是否有一种方法可以在一个应用程序中同时做这两件事?如果没有,我如何连接这两个项目?
更新:我尝试将VR播放器项目导出为自定义unity包,然后将其导入到我的主项目中,但随后所有2D页面都按预期工作,但播放器不响应移动
发布于 2019-05-07 19:44:29
在reddit上找到了一个人的答案。这对我来说太棒了!
在XR设置中添加虚拟支持,设置为None in cardboard(我假设这是cardboard?)。
然后使用此命令启动VR:
IEnumerator EnableCardboard() {
// Empty string loads the "None" device.
XRSettings.LoadDeviceByName("CardBoard");
// Must wait one frame after calling `XRSettings.LoadDeviceByName()`.
yield return null;
// Not needed, since loading the None (`""`) device takes care of
this.XRSettings.enabled = true;
}或者这样来停止虚拟现实:
public IEnumerator StopCardboard(){
XRSettings.LoadDeviceByName("");
yield return null;
XRSettings.enabled = false;
ResetCameras();
Screen.orientation = ScreenOrientation.Portrait;
}
void ResetCameras() {
// Camera looping logic copied from GvrEditorEmulator.cs
for (int i = 0; i < Camera.allCameras.Length; i++) {
Camera cam = Camera.allCameras[i];
if (cam.enabled && cam.stereoTargetEye != StereoTargetEyeMask.None) {
// Reset local position.
// Only required if you change the camera's local position while in 2D mode.
cam.transform.localPosition = Vector3.zero;
// Reset local rotation.
// Only required if you change the camera's local rotation while in 2D mode.
cam.transform.localRotation = Quaternion.identity;
// No longer needed, see issue github.com/googlevr/gvr-unity-sdk/issues/628.
// cam.ResetAspect();
// No need to reset `fieldOfView`, since it's reset automatically.
}
}
}请确保将它们称为协程,现在我只需要处理启动画面
https://stackoverflow.com/questions/56017697
复制相似问题