Forum Discussion
rcazzy
10 years agoProtege
0
0
9 Replies
Replies have been turned off for this discussion
- petereptProtegeNot 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 - vrdavebOculus 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;
} - rcazzyProtegeThank 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? - treytechExplorerTry 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;
} - petereptProtegeIf 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");
}); - rcazzyProtege
"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! :D
I'm going to be using your method for my next demo Peter, it looks really handy to use! - HannahTS95Honored GuestIs there a more recent solution to this problem? These answers don't seem to be compatible with OVRScreenFade anymore! Thank you!
- AlanOTooleAdventurer
HannahTS95 said:
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! - HannahTS95Honored GuestSorry, 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?
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 3 years ago
- 2 months ago