日本語翻訳ドキュメントはサポートを終了しました

MRTK 2.6 以降のドキュメントについては、公式の Microsoft ドキュメント を参照してください。

    Show / Hide Table of Contents

    Class PlayModeTestUtilities

    Inheritance
    Object
    PlayModeTestUtilities
    Inherited Members
    Object.ToString()
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Namespace: Microsoft.MixedReality.Toolkit.Tests
    Assembly: cs.temp.dll.dll
    Syntax
    public class PlayModeTestUtilities

    Fields

    UseSlowTestController

    If true, the controller movement test steps will take a longer number of frames. This is especially useful for seeing motion in play mode tests (where the default smaller number of frames tends to make tests too fast to be understandable to the human eye). This is false by default to ensure that tests will run quickly in general, and can be set to true manually in specific test cases using the example below.

    Declaration
    public static bool UseSlowTestController
    Field Value
    Type Description
    Boolean
    Remarks

    Note that this value is reset to false after each play mode test that uses PlayModeTestUtilities.Setup() - this is to reduce the chance that a forgotten UseSlowTestController = true ends up slowing all subsequent tests.

    Examples
    [UnityTest]
    public IEnumerator YourTestCase()
    {
        PlayModeTestUtilities.UseSlowTestController = true;
        ...
        PlayModeTestUtilities.UseSlowTestController = false;
    }

    Properties

    ControllerMoveSteps

    The number of frames that elapse for each test controller movement, taking into account if slow test controller mode has been engaged.

    Declaration
    public static int ControllerMoveSteps { get; }
    Property Value
    Type Description
    Int32

    HandMoveSteps

    The number of frames that elapse for each test controller movement, taking into account if slow test controller mode has been engaged.

    Declaration
    [Obsolete("Use ControllerMoveSteps instead.")]
    public static int HandMoveSteps { get; }
    Property Value
    Type Description
    Int32

    UseSlowTestHand

    If true, the controller movement test steps will take a longer number of frames. This is especially useful for seeing motion in play mode tests (where the default smaller number of frames tends to make tests too fast to be understandable to the human eye). This is false by default to ensure that tests will run quickly in general, and can be set to true manually in specific test cases using the example below.

    Declaration
    [Obsolete("Use UseSlowTestController instead.")]
    public static bool UseSlowTestHand { get; set; }
    Property Value
    Type Description
    Boolean
    Remarks

    Note that this value is reset to false after each play mode test that uses PlayModeTestUtilities.Setup() - this is to reduce the chance that a forgotten UseSlowTestController = true ends up slowing all subsequent tests.

    Examples
    [UnityTest]
    public IEnumerator YourTestCase()
    {
        PlayModeTestUtilities.UseSlowTestController = true;
        ...
        PlayModeTestUtilities.UseSlowTestController = false;
    }

    Methods

    CalculateNumSteps(Int32)

    Given a numSteps value, determines if the value is a 'sentinel' value of ControllerMoveStepsSentinelValue, which should be converted to the current default value of ControllerMoveSteps. If it's not the sentinel value, this returns numSteps unchanged.

    Declaration
    public static int CalculateNumSteps(int numSteps)
    Parameters
    Type Name Description
    Int32 numSteps
    Returns
    Type Description
    Int32

    EnsureInputModule()

    Make sure there is a MixedRealityInputModule on the main camera, which is needed for using Unity UI with MRTK.

    Declaration
    public static void EnsureInputModule()
    Remarks

    Workaround for #5061

    GenerateHandPose(ArticulatedHandPose.GestureId, Handedness, Vector3, Quaternion)

    Declaration
    public static SimulatedHandData.HandJointDataGenerator GenerateHandPose(ArticulatedHandPose.GestureId gesture, Handedness handedness, Vector3 worldPosition, Quaternion rotation)
    Parameters
    Type Name Description
    ArticulatedHandPose.GestureId gesture
    Handedness handedness
    Vector3 worldPosition
    Quaternion rotation
    Returns
    Type Description
    SimulatedHandData.HandJointDataGenerator

    GetInputSimulationService()

    Utility function to simplify code for getting access to the running InputSimulationService

    Declaration
    public static InputSimulationService GetInputSimulationService()
    Returns
    Type Description
    InputSimulationService

    Returns InputSimulationService registered for playmode test scene

    GetInputSystem()

    Declaration
    public static IMixedRealityInputSystem GetInputSystem()
    Returns
    Type Description
    IMixedRealityInputSystem

    GetPointer<T>(Handedness)

    Declaration
    public static T GetPointer<T>(Handedness handedness)
        where T : class, IMixedRealityPointer
    Parameters
    Type Name Description
    Handedness handedness
    Returns
    Type Description
    T
    Type Parameters
    Name Description
    T

    HideController(Handedness, InputSimulationService)

    Declaration
    public static IEnumerator HideController(Handedness handedness, InputSimulationService inputSimulationService)
    Parameters
    Type Name Description
    Handedness handedness
    InputSimulationService inputSimulationService
    Returns
    Type Description
    IEnumerator

    HideHand(Handedness, InputSimulationService)

    Declaration
    public static IEnumerator HideHand(Handedness handedness, InputSimulationService inputSimulationService)
    Parameters
    Type Name Description
    Handedness handedness
    InputSimulationService inputSimulationService
    Returns
    Type Description
    IEnumerator

    InstallTextMeshProEssentials()

    Declaration
    public static void InstallTextMeshProEssentials()

    MoveHand(Vector3, Vector3, ArticulatedHandPose.GestureId, Handedness, InputSimulationService, Int32)

    Moves the hand from startPos to endPos.

    Declaration
    public static IEnumerator MoveHand(Vector3 startPos, Vector3 endPos, ArticulatedHandPose.GestureId gestureId, Handedness handedness, InputSimulationService inputSimulationService, int numSteps = -1)
    Parameters
    Type Name Description
    Vector3 startPos
    Vector3 endPos
    ArticulatedHandPose.GestureId gestureId
    Handedness handedness
    InputSimulationService inputSimulationService
    Int32 numSteps
    Returns
    Type Description
    IEnumerator
    Remarks

    Note that numSteps defaults to a value of -1, which is a sentinel value to indicate that the default number of steps should be used (i.e. ControllerMoveSteps). ControllerMoveSteps is not a compile time constant, which is a requirement for default parameter values.

    MoveMotionController(Vector3, Vector3, SimulatedMotionControllerButtonState, Handedness, InputSimulationService, Int32)

    Moves the motion controller from startPos to endPos.

    Declaration
    public static IEnumerator MoveMotionController(Vector3 startPos, Vector3 endPos, SimulatedMotionControllerButtonState buttonState, Handedness handedness, InputSimulationService inputSimulationService, int numSteps = -1)
    Parameters
    Type Name Description
    Vector3 startPos
    Vector3 endPos
    SimulatedMotionControllerButtonState buttonState
    Handedness handedness
    InputSimulationService inputSimulationService
    Int32 numSteps
    Returns
    Type Description
    IEnumerator
    Remarks

    Note that numSteps defaults to a value of -1, which is a sentinel value to indicate that the default number of steps should be used (i.e. ControllerMoveSteps). ControllerMoveSteps is not a compile time constant, which is a requirement for default parameter values.

    PopControllerSimulationProfile()

    Declaration
    public static void PopControllerSimulationProfile()

    PopHandSimulationProfile()

    Declaration
    [Obsolete("Use PopControllerSimulationProfile instead.")]
    public static void PopHandSimulationProfile()

    PushControllerSimulationProfile()

    Declaration
    public static void PushControllerSimulationProfile()

    PushHandSimulationProfile()

    Declaration
    [Obsolete("Use PushControllerSimulationProfile instead.")]
    public static void PushHandSimulationProfile()

    SetControllerSimulationMode(ControllerSimulationMode)

    Declaration
    public static void SetControllerSimulationMode(ControllerSimulationMode mode)
    Parameters
    Type Name Description
    ControllerSimulationMode mode

    SetHandRotation(Quaternion, Quaternion, Vector3, ArticulatedHandPose.GestureId, Handedness, Int32, InputSimulationService)

    Declaration
    public static IEnumerator SetHandRotation(Quaternion fromRotation, Quaternion toRotation, Vector3 handPos, ArticulatedHandPose.GestureId gestureId, Handedness handedness, int numSteps, InputSimulationService inputSimulationService)
    Parameters
    Type Name Description
    Quaternion fromRotation
    Quaternion toRotation
    Vector3 handPos
    ArticulatedHandPose.GestureId gestureId
    Handedness handedness
    Int32 numSteps
    InputSimulationService inputSimulationService
    Returns
    Type Description
    IEnumerator

    SetHandSimulationMode(ControllerSimulationMode)

    Declaration
    [Obsolete("Use SetControllerSimulationMode instead.")]
    public static void SetHandSimulationMode(ControllerSimulationMode mode)
    Parameters
    Type Name Description
    ControllerSimulationMode mode

    SetHandState(Vector3, ArticulatedHandPose.GestureId, Handedness, InputSimulationService)

    Declaration
    public static IEnumerator SetHandState(Vector3 handPos, ArticulatedHandPose.GestureId gestureId, Handedness handedness, InputSimulationService inputSimulationService)
    Parameters
    Type Name Description
    Vector3 handPos
    ArticulatedHandPose.GestureId gestureId
    Handedness handedness
    InputSimulationService inputSimulationService
    Returns
    Type Description
    IEnumerator

    SetMotionControllerRotation(Quaternion, Quaternion, Vector3, SimulatedMotionControllerButtonState, Handedness, Int32, InputSimulationService)

    Declaration
    public static IEnumerator SetMotionControllerRotation(Quaternion fromRotation, Quaternion toRotation, Vector3 motionControllerPos, SimulatedMotionControllerButtonState buttonState, Handedness handedness, int numSteps, InputSimulationService inputSimulationService)
    Parameters
    Type Name Description
    Quaternion fromRotation
    Quaternion toRotation
    Vector3 motionControllerPos
    SimulatedMotionControllerButtonState buttonState
    Handedness handedness
    Int32 numSteps
    InputSimulationService inputSimulationService
    Returns
    Type Description
    IEnumerator

    SetMotionControllerState(Vector3, SimulatedMotionControllerButtonState, Handedness, InputSimulationService)

    Declaration
    public static IEnumerator SetMotionControllerState(Vector3 motionControllerPos, SimulatedMotionControllerButtonState buttonState, Handedness handedness, InputSimulationService inputSimulationService)
    Parameters
    Type Name Description
    Vector3 motionControllerPos
    SimulatedMotionControllerButtonState buttonState
    Handedness handedness
    InputSimulationService inputSimulationService
    Returns
    Type Description
    IEnumerator

    Setup(MixedRealityToolkitConfigurationProfile)

    Creates a play mode test scene, creates an MRTK instance, initializes playspace.

    Declaration
    public static void Setup(MixedRealityToolkitConfigurationProfile profile = null)
    Parameters
    Type Name Description
    MixedRealityToolkitConfigurationProfile profile
    Remarks

    Takes an optional MixedRealityToolkitConfigurationProfile used to initialize the MRTK.

    SetupMrtkWithoutGlobalInputHandlers()

    Initializes the MRTK such that there are no other input system listeners (global or per-interface).

    Declaration
    public static IEnumerator SetupMrtkWithoutGlobalInputHandlers()
    Returns
    Type Description
    IEnumerator

    ShowHand(Handedness, InputSimulationService)

    Shows the hand in the open state, at the origin

    Declaration
    public static IEnumerator ShowHand(Handedness handedness, InputSimulationService inputSimulationService)
    Parameters
    Type Name Description
    Handedness handedness
    InputSimulationService inputSimulationService
    Returns
    Type Description
    IEnumerator

    ShowHand(Handedness, InputSimulationService, ArticulatedHandPose.GestureId, Vector3)

    Declaration
    public static IEnumerator ShowHand(Handedness handedness, InputSimulationService inputSimulationService, ArticulatedHandPose.GestureId handPose, Vector3 handLocation)
    Parameters
    Type Name Description
    Handedness handedness
    InputSimulationService inputSimulationService
    ArticulatedHandPose.GestureId handPose
    Vector3 handLocation
    Returns
    Type Description
    IEnumerator

    ShowMontionController(Handedness, InputSimulationService)

    Shows the motion controller in the default state, at the origin

    Declaration
    public static IEnumerator ShowMontionController(Handedness handedness, InputSimulationService inputSimulationService)
    Parameters
    Type Name Description
    Handedness handedness
    InputSimulationService inputSimulationService
    Returns
    Type Description
    IEnumerator

    ShowMontionController(Handedness, InputSimulationService, SimulatedMotionControllerButtonState, Vector3)

    Declaration
    public static IEnumerator ShowMontionController(Handedness handedness, InputSimulationService inputSimulationService, SimulatedMotionControllerButtonState buttonState, Vector3 motionControllerLocation)
    Parameters
    Type Name Description
    Handedness handedness
    InputSimulationService inputSimulationService
    SimulatedMotionControllerButtonState buttonState
    Vector3 motionControllerLocation
    Returns
    Type Description
    IEnumerator

    TearDown()

    Destroys all objects in the play mode test scene, if it has been loaded, and shuts down MRTK instance.

    Declaration
    public static void TearDown()

    TeardownInputModule()

    Destroy the input module to ensure it gets initialized cleanly for the next test.

    Declaration
    public static void TeardownInputModule()
    Remarks

    Workaround for #5116

    UpdateMotionControllerPose(Handedness, Vector3, Quaternion)

    Declaration
    public static SimulatedMotionControllerData.MotionControllerPoseUpdater UpdateMotionControllerPose(Handedness handedness, Vector3 worldPosition, Quaternion rotation)
    Parameters
    Type Name Description
    Handedness handedness
    Vector3 worldPosition
    Quaternion rotation
    Returns
    Type Description
    SimulatedMotionControllerData.MotionControllerPoseUpdater

    WaitForEnterKey()

    Waits for the user to press the enter key before a test continues. Not actually used by any test, but it is useful when debugging since you can pause the state of the test and inspect the scene.

    Declaration
    public static IEnumerator WaitForEnterKey()
    Returns
    Type Description
    IEnumerator

    WaitForInputSystemUpdate()

    Sometimes it take a few frames for inputs raised via InputSystem.OnInput* to actually get sent to input handlers. This method waits for enough frames to pass so that any events raised actually have time to send to handlers. We set it fairly conservatively to ensure that after waiting all input events have been sent.

    Declaration
    public static IEnumerator WaitForInputSystemUpdate()
    Returns
    Type Description
    IEnumerator
    Back to top Generated by DocFX