Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Bentoon · Jun 22, 2017 at 09:31 PM · vrmobiledisabletoggleenable

enable & disable VR on mobile

Riffing off a question from @KristofferH

I have a mobile app and there is a button in the corner that I want to trigger a VR mode VRSettings.enabled

so you can put into cardboard (on IOs or Android)

in VR there is a button on the floor to go back to touchscreen mode

VRSettings.disabled

Doesn't work Does anyone have experience ?

Thanks

~be

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by SohailBukhari · Jun 23, 2017 at 08:39 AM

VRSettings.enabled Globally enables or disables VR for the application.

Set this to true to enable VR mode for the application. Note that this does not activate VR mode. VR mode is activated when a supported Head Mounted Display (HMD) is connected. The GearVR cannot be disabled once activated. A warning message is shown when attempting to disable a GearVR device.

Include using UnityEngine.VR; at the top.

Call VRSettings.LoadDeviceByName("") with empty string followed by VRSettings.enabled = false; to disable VR in the start function to disable VR.

When you want to enable it later on, call VRSettings.LoadDeviceByName("deviceName") with the VR name followed by VRSettings.enabled = true;.

You should wait for a frame between each function call. That requires this to be done a corutine function.

Also, On some VR devices, you must go to Edit->Project Settings->Player and make sure that Virtual Reality Supported check-box is checked(true) before this will work. Then you can disable it in the Start function and enable it whenever you want.

Note:

This is known to work on some VR devices and not all VR devices. Although, it should work on Daydream VR. Complete code sample:

 IEnumerator LoadDevice(string newDevice, bool enable)
 {
     VRSettings.LoadDeviceByName(newDevice);
     yield return null;
     VRSettings.enabled = enable;
 }
 
 void EnableVR()
 {
     StartCoroutine(LoadDevice("deviceName", true));
 }
 void DisableVR()
 {
     StartCoroutine(LoadDevice("", false));
 }

According to Unity, it wont work in the Editor. It will work in Standalone builds.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by FlaSh-G · Jun 23, 2017 at 07:52 AM

You can't just write

 VRSettings.enabled

It's a variable that has a value that you can change. More specifically: To true or false. So your VR-enable code is

 VRSettings.enabled = true;

and accordingly, disabling VR would be

 VRSettings.enabled = false;
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

108 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Please Help!!! Enable/Disable Script!!! 3 Answers

Help With Disabling/Enabling single GameObject 1 Answer

Toggling the light with lightmapping(baked and dynamic shadows) 1 Answer

Disabling first actor when switching to another camera. 0 Answers

Disabling/Enabling Different Character Controllers. 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges