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?
Answer by dsentence · Mar 08, 2017 at 09:59 AM
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.
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);
}
}
This worked great for me, thank you for posting it! $$anonymous$$uch obliged!
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?
Just use the FadeFromWhite() method
private void Start()
{
FadeFromWhite();
}
Hi many thanks for your reply, its working great now, it was just the invoke part that was throwing me.
Answer by SweatyChair · Apr 14, 2021 at 09:51 AM
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.
Your answer
![](https://koobas.hobune.stream/wayback/20220612094907im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Windows Mixed Reality HMD Translation not tracked in Unity scene 1 Answer
why does my view change 0 Answers
SteamVR Fading to Blue? 0 Answers