Search Unity

Question Turn the VR camera off

Discussion in 'VR' started by NotQuiteSmith, Jun 6, 2021.

  1. NotQuiteSmith

    NotQuiteSmith

    Joined:
    Oct 27, 2013
    Posts:
    92
    How do I turn the player's view off temporarily so they just see black? I'm in Unity 2020.3.9f1 using Unity XR. If I just disable the camera it "freezes" the current view (rather than going "off"). I use this when transitioning between scenes (and a few other reasons). A fade to black would be nice but not essential.

    Thanks!
     
  2. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    5,043
    I would recommend having a 100% black overlay on top of the camera since the camera basically is the VR headset. You can do this using a plane or just by having an (inverted) black sphere on top of the camera (as a child so it moves with the camera).
    You can simply make this fade from transparent to opaque to make it more comfortable for the player.
     
    NotQuiteSmith likes this.
  3. NotQuiteSmith

    NotQuiteSmith

    Joined:
    Oct 27, 2013
    Posts:
    92
    Thanks! I did try this (with a sphere and a simple ShaderGraph "two sided" material). However, I have some assets (Gaia and some text materials) that show through the black material (must be something to do with the order). I was hoping for a true "camera off" to avoid having to go through all the mats (particularly in assets) to try and figure out the problems :-(. Seems weird you can't turn it off.
     
  4. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    5,043
    This can be done using shaders:
    http://wiki.unity3d.com/index.php?title=3DText
    (Or just google "Unity text visible through objects")

    The default text is rendered as a canvas, which overlays everything.

    For absolutely optimal performance you can also just reverse the normals on the sphere instead of having it double sided.
     
    NotQuiteSmith likes this.