Class TestButtonUtilities
Utility class that provides helpful methods for generating and assembling buttons to be used in tests Also provides functions to test/simulate pressing buttons etc
Inherited Members
Namespace: Microsoft.MixedReality.Toolkit.Tests
Assembly: cs.temp.dll.dll
Syntax
public static class TestButtonUtilities
Fields
ButtonPressAnimationDelay
Amount of time for press action on button
Declaration
public const float ButtonPressAnimationDelay = 0.25F
Field Value
Type | Description |
---|---|
Single |
ButtonReleaseAnimationDelay
Amount of time for release action on button
Declaration
public const float ButtonReleaseAnimationDelay = 0.25F
Field Value
Type | Description |
---|---|
Single |
DefaultInteractablePrefabAssetPath
Asset path to default model push button prefab asset
Declaration
public static readonly string DefaultInteractablePrefabAssetPath
Field Value
Type | Description |
---|---|
String |
DefaultPosition
Default position of new interactable buttons instantiated
Declaration
public static readonly Vector3 DefaultPosition
Field Value
Type | Description |
---|---|
Vector3 |
DefaultRotation
Default rotation applied to new interactable button instantiated
Declaration
public static readonly Quaternion DefaultRotation
Field Value
Type | Description |
---|---|
Quaternion |
PressableHoloLens2PrefabPath
Asset path to default HoloLens 2 Pressable Button prefab asset
Declaration
public static readonly string PressableHoloLens2PrefabPath
Field Value
Type | Description |
---|---|
String |
PressableHoloLens2TogglePrefabPath
Asset path to default HoloLens 2 Toggle Pressable Button prefab asset
Declaration
public static readonly string PressableHoloLens2TogglePrefabPath
Field Value
Type | Description |
---|---|
String |
Methods
CheckButtonTranslation(Vector3, Transform, Boolean)
Confirms that provided Transform translates as expected due to a press currently happening
Declaration
public static IEnumerator CheckButtonTranslation(Vector3 targetStartPosition, Transform translateTarget, bool shouldTranslate = true)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | targetStartPosition | |
Transform | translateTarget | |
Boolean | shouldTranslate |
Returns
Type | Description |
---|---|
IEnumerator |
InstantiateDefaultButton(TestButtonUtilities.DefaultButtonType, out Interactable, out Transform)
Instantiate and configure one of the TestButtonUtilities.DefaultButtonType types. Returns reference to Interactable component and Transform to movable object that transforms on press
Declaration
public static void InstantiateDefaultButton(TestButtonUtilities.DefaultButtonType buttonType, out Interactable interactable, out Transform translateTargetObject)
Parameters
Type | Name | Description |
---|---|---|
TestButtonUtilities.DefaultButtonType | buttonType | |
Interactable | interactable | |
Transform | translateTargetObject |
Remarks
The button will be instantiated relative to the current MRTKPlayspace. This means its world transform will be the position and rotation baked into the prefab, applied relative to the MRTKPlayspace. See InstantiateInteractableFromPath(Vector3, Quaternion, String)
InstantiateInteractableFromPath(Vector3, Quaternion, String)
Instantiates Interactable prefab from provided asset database path at given position and rotation
Declaration
public static GameObject InstantiateInteractableFromPath(Vector3 position, Quaternion rotation, string path)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | position | |
Quaternion | rotation | |
String | path |
Returns
Type | Description |
---|---|
GameObject |
Remarks
The button will be instantiated relative to the current MRTKPlayspace. This means its world transform will be the position and rotation baked into the prefab, applied relative to the MRTKPlayspace.
InstantiatePressableButtonPrefab(Vector3, Quaternion, String, String, out Interactable, out Transform)
Instantiates Pressable Button based on list of arguments provided
Declaration
public static void InstantiatePressableButtonPrefab(Vector3 position, Quaternion rotation, string prefabPath, string translateTargetPath, out Interactable interactable, out Transform translateTargetTransform)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | position | |
Quaternion | rotation | |
String | prefabPath | |
String | translateTargetPath | |
Interactable | interactable | |
Transform | translateTargetTransform |
Remarks
The button will be instantiated relative to the current MRTKPlayspace. This means its world transform will be the position and rotation baked into the prefab, applied relative to the MRTKPlayspace. See InstantiateInteractableFromPath(Vector3, Quaternion, String)
MoveHand(Vector3, Vector3)
Move the right hand from point 1 to point 2
Declaration
public static IEnumerator MoveHand(Vector3 p1, Vector3 p2)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | p1 | |
Vector3 | p2 |
Returns
Type | Description |
---|---|
IEnumerator |
MoveHandAwayFromButton(Transform)
Move the right from in the button to just in front of the button
Declaration
public static IEnumerator MoveHandAwayFromButton(Transform button)
Parameters
Type | Name | Description |
---|---|---|
Transform | button |
Returns
Type | Description |
---|---|
IEnumerator |
MoveHandToButton(Transform)
Move the right hand from in front of the button through to the button
Declaration
public static IEnumerator MoveHandToButton(Transform button)
Parameters
Type | Name | Description |
---|---|---|
Transform | button |
Returns
Type | Description |
---|---|
IEnumerator |
TestClickPushButton(Transform, Vector3, Transform, Boolean)
Execute and test end-to-end press of a button with right hand poke pointer
Declaration
public static IEnumerator TestClickPushButton(Transform button, Vector3 targetStartPosition, Transform translateTargetObject, bool shouldClick = true)
Parameters
Type | Name | Description |
---|---|---|
Transform | button | Position of button to push hand to/through |
Vector3 | targetStartPosition | The start position of the button component that will translate on press |
Transform | translateTargetObject | Transform of the button component that will translate on press |
Boolean | shouldClick | Should we expect a click (i.e translation) from the button. The button may be disabled |
Returns
Type | Description |
---|---|
IEnumerator |