Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Cannot Toggle into VR mode from none settings

Discussion in 'Daydream' started by douglasfchan, Dec 20, 2016.

  1. douglasfchan

    douglasfchan

    Joined:
    Dec 15, 2016
    Posts:
    6
    I use Unity 5.4.2f2-GVR13 and Google VR SDK 1.03. In Player Settings, I set the Virtual Reality SDKs to none. I want to user click the button and switch from normal to VR mode with the following script but I fail.

    using UnityEngine;
    using UnityEngine.VR;
    using System.Collections;


    public classToggleVR : MonoBehaviour {

    IEnumerator LoadDevice (string Cardboard) {

    VRSettings.LoadDeviceByName(Cardboard);

    yield return null;

    VRSettings.enabled=true;

    Debug.Log("Changed VRSettings to Cardboard");

    }
    }

    Any hints?
    Do I need to drag and drop the GvrViewerMain.prefab onto the Scene?
    Which one, the Main Cinema or button drag onto the On Click () event of the button?
    Any sample can I follow? I have searched the whole forum and cannot find one.
     
  2. joejo

    joejo

    Unity Technologies

    Joined:
    May 26, 2016
    Posts:
    958
    What is the actual string value you are passing in to LoadDeviceByName?
     
  3. douglasfchan

    douglasfchan

    Joined:
    Dec 15, 2016
    Posts:
    6
    Cardboard.

    Anything wrong? I just use the name on the list of Virtual Reality SDKs of player settings
     
  4. joejo

    joejo

    Unity Technologies

    Joined:
    May 26, 2016
    Posts:
    958
    The name should be "cardboard" (lowercase). Try that.
     
  5. douglasfchan

    douglasfchan

    Joined:
    Dec 15, 2016
    Posts:
    6
    Still not work.
     
  6. joejo

    joejo

    Unity Technologies

    Joined:
    May 26, 2016
    Posts:
    958
    Please provide a simple, sample project that demonstrates the issue and we can look into it further.
     
  7. thep3000

    thep3000

    Unity Technologies

    Joined:
    Aug 9, 2013
    Posts:
    400
    You will need the cardboard SDK in your Virtual Reality SDK list in order to switch to it at runtime. So your list should have both None and Cardboard in it.
     
  8. douglasfchan

    douglasfchan

    Joined:
    Dec 15, 2016
    Posts:
    6
    These are all my steps, please see which one I miss:

    1. Download Daydream Tehnical Preview from https://unity3d.com/partners/google/daydream
    2. Launch Unity Daydream Preview
    3. Create a new project file called 'Unity Project Sample'
    4. Add a plane and a cube gameobjects onto the scene
    5. Change the view in 2D, and add a UI button with position x:0, y:0, z:0. (Image_1)
    6. Create a 'ToggleVR.cs' script. (Image_Script)
    7. Drag the script onto the 'Button'. (Image_2)
    8. Press '+' of On Click () on the Inspector of 'Button'. (Image_3)
    9. Drag the 'Button' from Hierarchy onto 'None (object) of On Click () event. (Image_4)
    10. In Build Settings, add open scenes and choose Android Platform. (Image_5)
    11. Press 'Switch Platform' in Build Settings.
    12. In Player Settings check 'Virtual Reality Supported', choose 'None' on the list, set 'Minimum API level' to Android 7.0 'Nougat', change name of 'Bundle Identifier' to com.ABC.Sample. (Image_6)
    13. Save Scene and Save Project.
    14. Press Play and Click 'Button' on runtime mode, nothing happen, the script for switch from normal to VR mode do not work. (Image_7)

    Do I need to download additional Cardboard SDK as custom package to import for Unity Daydream Preview 5.4.2f2-GVR13? But I cannot find one, only find Google VR SDK to download.
     

    Attached Files:

  9. douglasfchan

    douglasfchan

    Joined:
    Dec 15, 2016
    Posts:
    6
    This is the remain images, the image_6, image_7 and image_script .
     

    Attached Files:

  10. douglasfchan

    douglasfchan

    Joined:
    Dec 15, 2016
    Posts:
    6
    I cannot find a cardboard SDK to download. But only find Google VR SDK to download.
    I add None and Cardboard in the list but still do not work.
     
  11. GreenJoy

    GreenJoy

    Joined:
    Jul 1, 2016
    Posts:
    2
    for the return type of the method named "LoadDevice“,you should call "LoadDevice" like this
    "StartCoroutine (LoadDevice("cardboard"));"
    otherwise ,you can print some infomation like : Debug.Log("some log"); to see if this method have execute.
    hope it helpful.
     
  12. jeffries7

    jeffries7

    Joined:
    Jun 25, 2014
    Posts:
    59
    Has anyone gotten any further with this?
     
  13. guneyozsan

    guneyozsan

    Joined:
    Feb 1, 2012
    Posts:
    99
    You have to download and add Google's GVR SDK Unity package and import it into your project. Then you need to add Cardboard to the "Virtual Reality SDK" list in your Build Settings. Ticking "Virtual Reality Supported" is not enough. It only loads the SDK's you picked, which is in your case only "None". It should be "None" and "Cardboard" there, first mode being top.
     
    sonofbryce likes this.