-
Notifications
You must be signed in to change notification settings - Fork 1
Headset Fade
In the project assets, make sure you have a material using the Anivision/Fade
shader. (Currently, this material is under Assets/Materials/Vision /Blit
.
In the Forward Renderer, make sure there is a Blit Renderer Feature with the fade material set as the Blit material.
Whenever you create an instance of the HeadsetFade
script, drag the fade material into the Fade Blit Material
parameter.
To start a fade, call the StartFade
function from any script.
Similarly, to start an unfade, call the StartUnfade
function.
The fade script also has several events that other scripts can subscribe to:
-
OnFadeStart
: This event is triggered whenever a fade begins. -
OnFadeEnd
: This event is triggered whenever a fade ends. -
OnUnfadeStart
: This event is triggered whenever an unfade begins. -
OnUnfadeEnd
: This event is triggered whenever an unfade ends.
One thing to keep in mind is that if multiple scripts refer to the same Headset Fade instance, any events they subscribe to will still be called even if a different script initiated the fade. In a script, to ensure that functions subscribed to a HeadsetFade event only trigger when the fade was started by the script, refer to a unique instance of HeadsetFade only referenced by the script.
There are many instances where you want to fade out and fade back in, such as when turning flying on and off. There is a function FadeUnfadeCustomCallback
that you can use to accomplish this, and you can pass in functions to be used as callbacks for when the fade starts, when the fade ends, when the unfade starts, and when the unfade ends. If you wish to have the fade and unfade happen and invoke the events that you've already attached to the headset fader, you should use the FadeUnfadeWithEvents
function instead.
The Headset Fader
prefab is simply a game object with an instance of the HeadsetFade
script referencing the proper material. It can be dragged into any scene any amount of times, and should be passed to scripts as a parameter whenever they call for a HeadsetFade
script.