A test fixture for writing tests that use the input system. Can be derived from
or simply instantiated from another test fixture.
Inheritance
System.Object
InputTestFixture
public class InputTestFixture
public class MyInputTests : InputTestFixture
{
public override void Setup()
{
base.Setup();
InputSystem.RegisterLayout<MyDevice>();
}
[Test]
public void CanCreateMyDevice()
{
InputSystem.AddDevice<MyDevice>();
Assert.That(InputSystem.devices, Has.Exactly(1).TypeOf<MyDevice>());
}
}
Properties
The input runtime used during testing.
Declaration
public InputTestRuntime runtime { get; }
Property Value
Methods
Declaration
public static void AssertButtonPress<TState>(InputDevice device, TState state, params ButtonControl[] buttons)
where TState : struct, IInputStateTypeInfo
Parameters
Type Parameters
Declaration
public InputTestFixture.ActionConstraint Canceled(InputAction action, InputControl control = null)
Parameters
Returns
Declaration
public InputTestFixture.ActionConstraint Canceled<TInteraction>(InputAction action, InputControl control = null)
where TInteraction : IInputInteraction
Parameters
Returns
Type Parameters
Name |
Description |
TInteraction |
|
Declaration
public InputTestFixture.ActionConstraint Performed(InputAction action, InputControl control = null)
Parameters
Returns
Declaration
public InputTestFixture.ActionConstraint Performed<TInteraction>(InputAction action, InputControl control = null)
where TInteraction : IInputInteraction
Parameters
Returns
Type Parameters
Name |
Description |
TInteraction |
|
Declaration
public void Press(ButtonControl button, double absoluteTime = -1, double timeOffset = 0)
Parameters
Type |
Name |
Description |
ButtonControl |
button |
|
System.Double |
absoluteTime |
|
System.Double |
timeOffset |
|
Declaration
public void PressAndRelease(ButtonControl button, double absoluteTime = -1, double timeOffset = 0)
Parameters
Type |
Name |
Description |
ButtonControl |
button |
|
System.Double |
absoluteTime |
|
System.Double |
timeOffset |
|
Declaration
public void Release(ButtonControl button, double absoluteTime = -1, double timeOffset = 0)
Parameters
Type |
Name |
Description |
ButtonControl |
button |
|
System.Double |
absoluteTime |
|
System.Double |
timeOffset |
|
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 absoluteTime = -1, 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 |
absoluteTime |
|
System.Double |
timeOffset |
|
Type Parameters
Name |
Description |
TValue |
Value type of the given control.
|
var gamepad = InputSystem.AddDevice<Gamepad>();
Set(gamepad.leftButton, 1);
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()
Declaration
public InputTestFixture.ActionConstraint Started(InputAction action, InputControl control = null)
Parameters
Returns
Declaration
public InputTestFixture.ActionConstraint Started<TInteraction>(InputAction action, InputControl control = null)
where TInteraction : IInputInteraction
Parameters
Returns
Type Parameters
Name |
Description |
TInteraction |
|
Restore the state of the input system it had when the test was started.
Declaration
public virtual void TearDown()
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.
|
Declaration
public void Trigger<TValue>(InputAction action, InputControl<TValue> control, TValue value)
where TValue : struct
Parameters
Type Parameters
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.