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

VRTK_SharedMethods

Overview

The Shared Methods script is a collection of reusable static methods that are used across a range of different scripts.

Class Methods

GetBounds/3

public static Bounds GetBounds(Transform transform, Transform excludeRotation = null, Transform excludeTransform = null)

  • Parameters
  • Transform transform -
  • Transform excludeRotation - Resets the rotation of the transform temporarily to 0 to eliminate skewed bounds.
  • Transform excludeTransform - Does not consider the stated object when calculating the bounds.
  • Returns
  • Bounds - The bounds of the transform.

The GetBounds methods returns the bounds of the transform including all children in world space.

IsLowest/2

public static bool IsLowest(float value, float[] others)

  • Parameters
  • float value - The value to check to see if it is lowest.
  • float[] others - The array of values to check against.
  • Returns
  • bool - Returns true if the value is lower than all numbers in the given array, returns false if it is not the lowest.

The IsLowest method checks to see if the given value is the lowest number in the given array of values.

AddCameraFade/0

public static Transform AddCameraFade()

  • Parameters
  • none
  • Returns
  • Transform - The transform of the headset camera.

The AddCameraFade method finds the headset camera and adds a headset fade script to it.

CreateColliders/1

public static void CreateColliders(GameObject obj)

  • Parameters
  • GameObject obj - The game object to attempt to add the colliders to.
  • Returns
  • none

The CreateColliders method attempts to add box colliders to all child objects in the given object that have a renderer but no collider.

CloneComponent/3

public static Component CloneComponent(Component source, GameObject destination, bool copyProperties = false)

  • Parameters
  • Component source - The component to copy.
  • GameObject destination - The game object to copy the component to.
  • bool copyProperties - Determines whether the properties of the component as well as the fields should be copied.
  • Returns
  • Component - The component that has been cloned onto the given game object.

The CloneComponent method takes a source component and copies it to the given destination game object.

ColorDarken/2

public static Color ColorDarken(Color color, float percent)

  • Parameters
  • Color color - The source colour to apply the darken to.
  • float percent - The percent to darken the colour by.
  • Returns
  • Color - The new colour with the darken applied.

The ColorDarken method takes a given colour and darkens it by the given percentage.

IsEditTime/0

public static bool IsEditTime()

  • Parameters
  • none
  • Returns
  • bool - Returns true if Unity is in the Unity Editor and not in play mode.

The IsEditTime method determines if the state of Unity is in the Unity Editor and the scene is not in play mode.