The fixture will put the input system into a known state where it has only the
built-in set of basic layouts and no devices. The state of the system before
starting a test is recorded and restored when the test finishes.
The test fixture will also sever the tie of the input system to the Unity runtime.
This means that while the test fixture is active, the input system will not receive
input and device discovery or removal notifications from platform code. This ensures
that while the test is running, input that may be generated on the machine running
the test will not infer with it.
Properties
currentTime
Get or set the current time used by the input system.
If true, no Update() will be performed after queueing the event. This will only put
the state event on the event queue and not do anything else. The default is to call Update() after queuing the event.
Note that not issuing an update means the state of the device will not change yet. This may affect subsequent Set/Press/Release/etc calls
as they will not yet see the state change.
Note that this parameter will be ignored if the test is a <code>[UnityTest]</code>. Multi-frame
playmode tests will automatically process input as part of the Unity player loop.
Type Parameters
Name
Description
TValue
Value type of the given control.
Examples
var gamepad = InputSystem.AddDevice<Gamepad>();
Set(gamepad.leftButton, 1);
If true, no Update() will be performed after queueing the event. This will only put
the state event on the event queue and not do anything else. The default is to call Update() after queuing the event.
Note that not issuing an update means the state of the device will not change yet. This may affect subsequent Set/Press/Release/etc calls
as they will not yet see the state change.
Note that this parameter will be ignored if the test is a <code>[UnityTest]</code>. Multi-frame
playmode tests will automatically process input as part of the Unity player loop.
Type Parameters
Name
Description
TValue
Value type of the control.
Examples
var device = InputSystem.AddDevice("TestDevice");
Set<ButtonControl>(device, "button", 1);
Set<AxisControl>(device, "{Primary2DMotion}/x", 123.456f);
Setup()
Put InputSystem into a known state where it only has a basic set of
layouts and does not have any input devices.
Declaration
[SetUp]
publicvirtualvoidSetup()
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.
public InputTestFixture.ActionConstraint Started<TInteraction>(InputAction action, InputControl control = null, objectvalue = null, double? time = null) where TInteraction : IInputInteraction
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.
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.