Steam VR Fade camera

I know Steam VR has a fade script. Of course without being a programmer it’s hard to get that to work. So I wondered if anyone had a working example they could show me?

I’m just going to leave this here, for if someone else is having trouble getting the steamvr fading to work.

What worked for me was to add the SteamVR_Fade script from the steamvr unity package to the camera child object under the [CameraRig] which has the SteamVR_Camera script on it. I believe in the standard prefab its the “Camera (eye)” object.

89550-capture.png

Then when I want to fade I just call the static SteamVR_Fade.Start method.

Test script I Used:

using UnityEngine;

public class SteamVrFadeTest : MonoBehaviour 
{
    private float _fadeDuration = 2f;

    private void Start()
    {
        FadeToWhite();
        Invoke("FadeFromWhite", _fadeDuration);
    }

    private void FadeToWhite()
    {
        //set start color
        SteamVR_Fade.Start(Color.clear, 0f);
        //set and start fade to
        SteamVR_Fade.Start(Color.white, _fadeDuration);
    }

    private void FadeFromWhite()
    {
        //set start color
        SteamVR_Fade.Start(Color.white, 0f);
        //set and start fade to
        SteamVR_Fade.Start(Color.clear, _fadeDuration);
    }
}

Hi,
I have attached the steamVR fade script to the camera(eye) and then attached your script above to a random object, the script works ok but I just want it to fade from white and not the double fade, to and from, whats the correct syntax for this to work correctly?

Addiction to @dsentence 's answer, if you want to fade out on scene change, you can simply use the SteamVR_LoadLevel:

Valve.VR.SteamVR_LoadLevel.Begin(sceneName);

P.S. you can input the background color and fade out time.