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

VRTK_MaterialColorSwapHighlighter

extends VRTK_BaseHighlighter

Overview

The Material Colour Swap Highlighter is a basic implementation that simply swaps the texture colour for the given highlight colour.

Due to the way the object material is interacted with, changing the material colour will break Draw Call Batching in Unity whilst the object is highlighted.

The Draw Call Batching will resume on the original material when the item is no longer highlighted.

This is the default highlighter that is applied to any script that requires a highlighting component (e.g. VRTK_Interactable_Object or VRTK_ControllerActions).

Inspector Parameters

  • Emission Darken: The emission colour of the texture will be the highlight colour but this percent darker.

Class Methods

Initialise/2

public override void Initialise(Color? color = null, Dictionary<string, object> options = null)

  • Parameters
  • Color? color - Not used.
  • Dictionary<string, object> options - A dictionary array containing the highlighter options:\r * <'resetMainTexture', bool> - Determines if the default main texture should be cleared on highlight. true to reset the main default texture, false to not reset it.
  • Returns
  • none

The Initialise method sets up the highlighter for use.

Highlight/2

public override void Highlight(Color? color, float duration = 0f)

  • Parameters
  • Color? color - The colour to highlight to.
  • float duration - The time taken to fade to the highlighted colour.
  • Returns
  • none

The Highlight method initiates the change of colour on the object and will fade to that colour (from a base white colour) for the given duration.

Unhighlight/2

public override void Unhighlight(Color? color = null, float duration = 0f)

  • Parameters
  • Color? color - Not used.
  • float duration - Not used.
  • Returns
  • none

The Unhighlight method returns the object back to it's original colour.

Example

VRTK/Examples/005_Controller_BasicObjectGrabbing demonstrates the solid highlighting on the green cube, red cube and flying saucer when the controller touches it.

VRTK/Examples/035_Controller_OpacityAndHighlighting demonstrates the solid highlighting if the right controller collides with the green box or if any of the buttons are pressed.