Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

VR Switch between normal Camera and VR Camera

Discussion in '5.1 Beta' started by S_P_S, Jun 1, 2015.

  1. S_P_S

    S_P_S

    Joined:
    Feb 25, 2015
    Posts:
    91
    Hello,

    I have made a little test scene, where I can switch between a normal camera and a VR camera by pressing a key.

    I start in "non-VR" mode. The desktop shows me the "non-VR" Camera and the Oculus Rift is black. Perfect!
    - VRSettings.enabled = false;
    - VRCam.SetActive(false);
    - MenuCam.SetActive(true);

    Now I press a key and the desktop shows me the VR-Camera. Also the Oculus shows me the VR-Camera and I can take my Oculus and use it as expected. Perfect!
    - MenuCam.SetActive(false);
    - VRCam.SetActive(true);
    - VRSettings.enabled = ftrue;

    Now I want to go back from VR to nonVR (like I started the game). The desktop view now shows me the nonVR Camera as it should and also the Oculus isn't working anymore, but the Oculus screen did not turned black, it freezed at the VR Cameras last frame (or one of the last frames).
    - VRCam.SetActive(false);
    - VRSettings.enabled = false;
    - VRCam.SetActive(false);
    - MenuCam.SetActive(true);

    But I want that the Oculus screen turns black when I disable the VRSettings, because I think its very misleading for the user, if the Oculus shows one stiff picture but should not be used at this time.

    I hope someone can hel.

    Regards
     
  2. Gruguir

    Gruguir

    Joined:
    Nov 30, 2010
    Posts:
    340
    Hey, just an untested idea but maybe you could try to use "VRSettings.loadedDevice", something like "VR.VRSettings.loadedDevice = null;" ?
     
  3. S_P_S

    S_P_S

    Joined:
    Feb 25, 2015
    Posts:
    91
    Thanks for your reply and idea, but I doesn't work in my case.
    In Editor playmode the playmode cancels and in a build application the game crashes.

    Anyway thanks for your idea. I am open for new ideas too :D

    Regards
     
  4. S_P_S

    S_P_S

    Joined:
    Feb 25, 2015
    Posts:
    91
    I noticed another strange behaviour.

    When I hit play I see my normal Camera. Than I hit return and I am changing to the VRCamera. I see the VRCamera in my Rift but the picture is freezed (no headtracking and no screen movement; also on the desktop).

    Than I have to click with my mouse on the screen and than its not freezed anymore. This happens only the first time I change from the "normal" Camera to the VRCam.

    I don't no what causes this? Help would be awesome.

    EDIT: In the finished builded game, the game minimises instead of freezing. When I than maximize again, everything is good. This only happens in DirectMode!

    Regards
     
    Last edited: Jun 3, 2015
  5. EdBlais

    EdBlais

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    311
    @_Beyond_ Given the current solution that you have, if you want the Oculus to have a black screen, you need to clear the camera to black and render nothing on the final frame before disabling VR. We are also working on a fix to the VRSettings.loadedDevice crash in the standalone player.
     
  6. S_P_S

    S_P_S

    Joined:
    Feb 25, 2015
    Posts:
    91
    Okay thanks, I will try this!

    Regrads