Skip to main content
Up and Coming
February 7, 2016

0

0

    This topic has been closed for replies.

    9 replies

    Up and Coming
    February 7, 2016
    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
    Check out my Unity VR development blog: http://talesfromtherift.com @peterept
    Inspiring
    February 7, 2016
    +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;
    }
    rcazzyAuthor
    Up and Coming
    March 2, 2016
    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?
    Up and Coming
    March 2, 2016
    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;
    }
    Up and Coming
    March 3, 2016
    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");
    });
    Check out my Unity VR development blog: http://talesfromtherift.com @peterept
    rcazzyAuthor
    Up and Coming
    March 3, 2016
    "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!
    New Participant
    October 27, 2018
    Is there a more recent solution to this problem? These answers don't seem to be compatible with OVRScreenFade anymore! Thank you!
    Inspiring
    October 29, 2018


    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!
    AlanOToole.com Twitter: @Alan_OToole
    New Participant
    October 30, 2018
    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?