Guides
Guides

VRTK_HeadsetFade

Overview

Provides the ability to change the colour of the headset view to a specified colour over a given duration.

Script Usage:

  • Place the VRTK_HeadsetFade script on any active scene GameObject.

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.

  • All C# delegate events are mapped to a Unity Event with the On prefix. e.g. MyEvent -> OnMyEvent.

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.