Class InputTestFixture | Package Manager UI website
docs.unity3d.com
    Show / Hide Table of Contents

    Class InputTestFixture

    Inheritance
    System.Object
    InputTestFixture
    Inherited Members
    System.Object.ToString()
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    Namespace: UnityEngine.Experimental.Input
    Syntax
    public class InputTestFixture

    Properties

    runtime

    The input runtime used during testing.

    Declaration
    public InputTestRuntime runtime { get; }
    Property Value
    Type Description
    InputTestRuntime

    Methods

    AssertButtonPress<TState>(InputDevice, TState, ButtonControl[])

    Declaration
    public void AssertButtonPress<TState>(InputDevice device, TState state, params ButtonControl[] buttons)where TState : struct, IInputStateTypeInfo
    Parameters
    Type Name Description
    InputDevice device
    TState state
    ButtonControl[] buttons
    Type Parameters
    Name Description
    TState

    Set<TValue>(InputControl<TValue>, TValue, Double)

    Set the control to the given value by sending a state event with the value to the control's device.

    Declaration
    public void Set<TValue>(InputControl<TValue> control, TValue state, double timeOffset = 0)where TValue : struct
    Parameters
    Type Name Description
    InputControl<TValue> control

    An input control on a device that has been added to the system.

    TValue state

    New value for the input control.

    System.Double timeOffset
    Type Parameters
    Name Description
    TValue

    Value type of the given control.

    Examples
    var gamepad = InputSystem.AddDevice<Gamepad>();
    Set(gamepad.leftButton, 1);

    Setup()

    Put InputSystem into a known state where it only has a basic set of layouts and does not have any input devices.

    Declaration
    public virtual void Setup()
    Remarks

    If you derive your own test fixture directly from InputTestFixture, this method will automatically be called. If you embed InputTestFixture into your fixture, you have to explicitly call this method yourself.

    TearDown()

    Restore the state of the input system it had when the test was started.

    Declaration
    public virtual void TearDown()

    Trigger(InputAction)

    Perform the input action without having to know what it is bound to.

    Declaration
    public void Trigger(InputAction action)
    Parameters
    Type Name Description
    InputAction action

    An input action that is currently enabled and has controls it is bound to.

    Remarks

    Blindly triggering an action requires making a few assumptions. Actions are not built to be able to trigger without any input. This means that this method has to generate input on a control that the action is bound to.

    Note that this method has no understanding of the interactions that may be present on the action and thus does not know how they may affect the triggering of the action.

    Trigger<TValue>(InputAction, InputControl<TValue>, TValue)

    Declaration
    public void Trigger<TValue>(InputAction action, InputControl<TValue> control, TValue value)where TValue : struct
    Parameters
    Type Name Description
    InputAction action
    InputControl<TValue> control
    TValue value
    Type Parameters
    Name Description
    TValue
    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023