cancel
Showing results for 
Search instead for 
Did you mean: 

0

rcazzy
Protege

0

9 REPLIES 9

peterept
Protege
Not using OVRScreenFade, but you could use the code I posted for creating splash screens fade in/out:

http://talesfromtherift.com/vr-splash/

Basically, this can be done easily with Canvas UI Group Panel set to Black that is parented to the camera when you want to fade in/out. Then use an animation curve to animate the transparency for the fade effect.

HTH,

Peter

vrdaveb
Oculus Staff
+1 for peterept's solution. If you really want to modify OVRScreenFade to support a fade-out, add something like this to it and then call StartFade() a couple of seconds before you switch scenes:
	public void StartFade()
{
StartCoroutine(FadeOut());
}

/// <summary>
/// Fades alpha from 0.0 to 1.0
/// </summary>
IEnumerator FadeOut()
{
float elapsedTime = 0.0f;
fadeMaterial.color = fadeColor;
Color color = fadeColor;
isFading = true;
while (elapsedTime < fadeTime)
{
yield return fadeInstruction;
elapsedTime += Time.deltaTime;
color.a = Mathf.Clamp01(elapsedTime / fadeTime);
fadeMaterial.color = color;
}
isFading = false;
}

rcazzy
Protege
Thank you both, both methods were interesting to test out.

I went with the OVR Screen Fade method in this case just for ease for myself.
I've found when I call the StartFade the screen will flash black for a brief second then the fade starts. Can you think of any reason why this would be occuring?

treytech
Explorer
Try this (untested by me):


IEnumerator FadeOut()
{
float elapsedTime = 0.0f;
Color color = fadeColor;
color.a = 0f;
fadeMaterial.color = color;
isFading = true;
while (elapsedTime < fadeTime)
{
yield return fadeInstruction;
elapsedTime += Time.deltaTime;
color.a = Mathf.Clamp01(elapsedTime / fadeTime);
fadeMaterial.color = color;
}
isFading = false;
}

peterept
Protege
If it helps, attached is the script I used with animations to fade in, fade out and fade in-out.

Drag the prefab as a child of your main camera.

When you want to fade out, just use:

Fader.Instance.FadeOut(() =>
{
Application.LoadLevel("Game");
});

rcazzy
Protege
"treytech" wrote:
Try this (untested by me):


IEnumerator FadeOut()
{
float elapsedTime = 0.0f;
Color color = fadeColor;
color.a = 0f;
fadeMaterial.color = color;
isFading = true;
while (elapsedTime < fadeTime)
{
yield return fadeInstruction;
elapsedTime += Time.deltaTime;
color.a = Mathf.Clamp01(elapsedTime / fadeTime);
fadeMaterial.color = color;
}
isFading = false;
}


This works perfectly! Thank you so much! 😄
I'm going to be using your method for my next demo Peter, it looks really handy to use!

HannahTS95
Honored Guest
Is there a more recent solution to this problem? These answers don't seem to be compatible with OVRScreenFade anymore! Thank you!

AlanOToole
Adventurer


Is there a more recent solution to this problem? These answers don't seem to be compatible with OVRScreenFade anymore! Thank you!


Hey @HannahTS95

Which version of the SDK are you using? There is now a native .FadeOut() function within OVRScreenFade.

Check for this:
    /// <summary>
/// Start a fade out
/// </summary>
public void FadeOut()
{
StartCoroutine(Fade(0,1));
}

Hope this helps!

HannahTS95
Honored Guest
Sorry, I am very new to coding in C#! Is there a way to call OVRScreenFade from another script so I can use .FadeOut() on a trigger?