Guides
Guides
These docs are for v2.2.1. Click to read the latest docs for v3.3.0.

VRTK_HeadsetFade

Overview

The purpose of the Headset Fade is to change the colour of the headset view to a specified colour over a given duration and to also unfade it back to being transparent. The Fade and Unfade methods can only be called via another script and this Headset Fade script does not do anything on initialisation to fade or unfade the headset view.

Unity Version Information

  • If using Unity 5.3 or older then the Headset Fade script is attached to the Camera(head) object within the [CameraRig] prefab.
  • If using Unity 5.4 or newer then the Headset Fade script is attached to the Camera(eye) object within the [CameraRig]->Camera(head) prefab.

Class Events

  • HeadsetFadeStart - Emitted when the user's headset begins to fade to a given colour.
  • HeadsetFadeComplete - Emitted when the user's headset has completed the fade and is now fully at the given colour.
  • HeadsetUnfadeStart - Emitted when the user's headset begins to unfade back to a transparent colour.
  • HeadsetUnfadeComplete - Emitted when the user's headset has completed unfading and is now fully transparent again.

Unity Events

Adding the VRTK_HeadsetFade_UnityEvents component to VRTK_HeadsetFade object allows access to UnityEvents that will react identically to the Class Events.

  • OnHeadsetFadeStart - Emits the HeadsetFadeStart class event.
  • OnHeadsetFadeComplete - Emits the HeadsetFadeComplete class event.
  • OnHeadsetUnfadeStart - Emits the HeadsetUnfadeStart class event.
  • OnHeadsetUnfadeComplete - Emits the HeadsetUnfadeComplete class event.

Event Payload

  • float timeTillComplete - A float that is the duration for the fade/unfade process has remaining.
  • Transform currentTransform - The current Transform of the object that the Headset Fade script is attached to (Camera).

Class Methods

IsFaded/0

public virtual bool IsFaded()

  • Parameters
  • none
  • Returns
  • bool - Returns true if the headset is currently fading or faded.

The IsFaded method returns true if the headset is currently fading or has completely faded and returns false if it is completely unfaded.

IsTransitioning/0

public virtual bool IsTransitioning()

  • Parameters
  • none
  • Returns
  • bool - Returns true if the headset is currently in the process of fading or unfading.

The IsTransitioning method returns true if the headset is currently fading or unfading and returns false if it is completely faded or unfaded.

Fade/2

public virtual void Fade(Color color, float duration)

  • Parameters
  • Color color - The colour to fade the headset view to.
  • float duration - The time in seconds to take to complete the fade transition.
  • Returns
  • none

The Fade method initiates a change in the colour of the headset view to the given colour over a given duration.

Unfade/1

public virtual void Unfade(float duration)

  • Parameters
  • float duration - The time in seconds to take to complete the unfade transition.
  • Returns
  • none

The Unfade method initiates the headset to change colour back to a transparent colour over a given duration.

Example

VRTK/Examples/011_Camera_HeadSetCollisionFading has collidable walls around the play area and if the user puts their head into any of the walls then the headset will fade to black.