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

VRTK_DeviceFinder

Overview

The Device Finder offers a collection of static methods that can be called to find common game devices such as the headset or controllers, or used to determine key information about the connected devices.

Class Methods

ControllerByIndex/1

public static SteamVR_TrackedObject ControllerByIndex(uint index)

  • Parameters
  • uint index - The index of the tracked object to find. Must be of type ETrackedDeviceClass.Controller.
  • Returns
  • SteamVR_TrackedObject - The object that matches the given index.

The ControllerByIndex method is used to find a SteamVR_TrackedObject by it's generated index. This is useful for finding controllers when only the index is known.

GetControllerIndex/1

public static uint GetControllerIndex(GameObject controller)

  • Parameters
  • GameObject Controller - The controller object to check the index on.
  • Returns
  • uint - The index of the given controller.

The GetControllerIndex method is used to find the index of a given controller object.

TrackedObjectByIndex/1

public static SteamVR_TrackedObject TrackedObjectByIndex(uint controllerIndex)

  • Parameters
  • uint index - The index of the tracked object to find.
  • Returns
  • SteamVR_TrackedObject - The object that matches the given index.

The TrackedObjectByIndex method is used to find a SteamVR_TrackedObject by it's generated index. This method will loop over all SteamVR_TrackedObjects in the scene until the relevant index is found so it is less efficient than using ControllerByIndex/1 to find a controller, but is useful for finding other tracked objects.

GetControllerHandType/1

public static ControllerHand GetControllerHandType(string hand)

  • Parameters
  • string hand - The string representation of the hand to retrieve the type of. left or right.
  • Returns
  • ControllerHand - An enum representing either the Left or Right hand.

The GetControllerHandType method is used for getting the enum representation of ControllerHand from a given string.

GetControllerHand/1

public static ControllerHand GetControllerHand(GameObject controller)

  • Parameters
  • GameObject controller - The controller game object to check the hand of.
  • Returns
  • ControllerHand - An enum representing either the Left or Right hand.

The GetControllerHand method is used for getting the enum representation of ControllerHand for the given controller game object.

IsControllerOfHand/2

public static bool IsControllerOfHand(GameObject checkController, ControllerHand hand)

  • Parameters
  • GameObject checkController - The actual controller object that is being checked.
  • ControllerHand hand - The enum representation of a hand to check if the given controller matches.
  • Returns
  • bool - Is true if the given controller matches the given hand.

The IsControllerOfHand method is used to check if a given controller game object is of the hand type provided.

HeadsetTransform/0

public static Transform HeadsetTransform()

  • Parameters
  • none
  • Returns
  • Transform - The transform of the VR Headset component.

The HeadsetTransform method is used to retrieve the transform for the VR Headset in the scene. It can be useful to determine the position of the user's head in the game world.

HeadsetCamera/0

public static Transform HeadsetCamera()

  • Parameters
  • none
  • Returns
  • Transform - The transform of the VR Camera component.

The HeadsetCamera method is used to retrieve the transform for the VR Camera in the scene.