Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
rcazzy's avatar
rcazzy
Protege
10 years ago

0

0

9 Replies

Replies have been turned off for this discussion
  • 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
  • +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;
    }
  • 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?
  • 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;
    }
  • 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");
    });
  • "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!
  • Is there a more recent solution to this problem? These answers don't seem to be compatible with OVRScreenFade anymore! Thank you!


  • 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!
  • 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?