简体   繁体   English

Unity VR场景到2D场景

[英]Unity VR scene to 2D scene

Does anyone have any idea how to switch unity VR mode scene to normal 2D scene? 有谁知道如何将统一VR模式场景切换到普通2D场景? i have number of 2D and VR scenes in my application and want a button through which user can enter into VR scene and after then easily return back to normal 2D scenes. 我的应用程序中有很多2D和VR场景,并希望有一个按钮,用户可以通过该按钮进入VR场景,然后轻松返回正常的2D场景。 I successfully done switching scene between 2D to VR but now my app stuck in VR to 2D switching. 我成功地完成了从2D到VR的切换场景,但是现在我的应用程序陷入了VR到2D的切换。

If you look into the documentation on Hybrid Apps with Google VR , it explains how you can go between 2D and VR. 如果您查看带有Google VR的Hybrid Apps上的文档,它说明了如何在2D和VR之间切换。

Essentially, you will have to include under the Player Settings -> XR Settings -> Virtual Reality SDKs the "None" SDK. 本质上,您必须在“ 播放器设置”->“ XR设置”->“虚拟现实” SDK下包括“无” SDK。 You may want to use something like string vrDeviceName = XRSettings.loadedDeviceName to store what your VR SDK is when in VR. 您可能想要使用string vrDeviceName = XRSettings.loadedDeviceName来存储VR中的VR SDK。

You also have to be familiar with using Coroutines , since when you change the view VR view type, you need to wait one frame. 您还必须熟悉使用协程 ,因为当您更改视图VR视图类型时,您需要等待一帧。

To switch to 2D, you have to start a coroutine call XRSettings.LoadDeviceByName(""); 要切换到2D,必须启动协程调用XRSettings.LoadDeviceByName(""); and wait one frame, and then adjust the camera (if needed). 然后等待一帧,然后调整相机(如果需要)。

To switch back to VR, you start a coroutine to do XRSettings.LoadDeviceByName(vrDeviceName); 要切换回VR,请启动协程以执行XRSettings.LoadDeviceByName(vrDeviceName); and again wait one frame. 再等一帧。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM