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 /
  • Help Room /
avatar image
0
Question by nice-nate · Apr 06, 2017 at 07:26 PM · vrscenescene-switchinggooglescene change

How to navigate from a non-VR scene to a VR enabled scene within Android

I have created the following script to take me to another scene on the press of a button.

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.SceneManagement;
 
 public class ChangeScene : MonoBehaviour
 {
     public void changeToScene(int changeTheScene)
     {
         SceneManager.LoadScene(changeTheScene);
     }
 }

My app crashes when I navigate from a non-vr scene to a vr scene when I use this code. Is there something I need to be including within the script to stop the application from crashing?

I am using the headset demo scene from v1.0.0 of the gvr-unity-sdk as my VR scene. My non-VR is composed of a canvas with a button and gameobject to hold the above script.

I've looked through the documentation for a couple hours while using NurFACEGAMES tutorials to try to get a better handle on the subject, but I've come up with nothing so far. Any help is appreciated.

First time poster, apologies for any rules I may have broken in this question.

Comment
Add comment · Show 1
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 nice-nate · Apr 07, 2017 at 02:28 AM 0
Share

So I am pursuing the possibility that the GvrViewer.Instance.VR$$anonymous$$odeEnabled has something to do with my ability to launch the next scene.

$$anonymous$$y issue now is that I am receiving an error which says no GvrViewer Instance has been found. This makes sense because the scene I am on is non-VR therefore there is no viewer.

I am now trying to get the script to reference the GvrViewer in the VR scene before setting VR$$anonymous$$odeEnabled to true.

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by nice-nate · Apr 07, 2017 at 03:41 AM

Fixed the problem by:

  1. Importing UnityEngine.VR; to a new script

  2. coded VRSettings.enabled = false; in start function when my first scene loads (currently trying to add the script to the unity splash screen, but that is a different question)

  3. Adding the script to a new game object on my first scene.

Hopefully this can eventually help someone in the future.

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
1

Answer by jeromeWork · Feb 07, 2018 at 11:13 AM

@nice-nate's answer was correct but I think things have changed in more recent releases: https://developers.google.com/vr/develop/unity/guides/hybrid-apps

Appears you now have to include 'None' as an SDK options in your Player Settings > XRSettings. Place it first in the list to start in non-VR.

Code to switch into VR is then:

     // Call via `StartCoroutine(SwitchToVR())` from your code. Or, use
     // `yield SwitchToVR()` if calling from inside another coroutine.
     IEnumerator SwitchToVR() {
       // Device names are lowercase, as returned by `XRSettings.supportedDevices`.
 // Google original, makes you specify
       //string desiredDevice = "daydream"; // Or "cardboard".
       //XRSettings.LoadDeviceByName(desiredDevice);
 // this is slightly better;
       string[] DaydreamDevices = new string[] { "daydream", "cardboard" };
        XRSettings.LoadDeviceByName(DaydreamDevices);
 
       // Must wait one frame after calling `XRSettings.LoadDeviceByName()`.
       yield return null;
     
       // Now it's ok to enable VR mode.
       XRSettings.enabled = true;
     }
 
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

124 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 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

Save and load scene from file 2 Answers

Switching between a VR and non VR scene 1 Answer

Keeping track of the previous scene 1 Answer

Loading and Unloading scenes 2 Answers

Trouble set the scene active with SceneMananger 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