Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Question [InputTestFixture] Updates to Gamepad Stick Input ignored after initial Set

Discussion in 'Input System' started by leohilbert, Jul 22, 2022.

  1. leohilbert


    Nov 28, 2015
    I'm currently starting out to write automated UnityTests for my project.
    I'm using the "InputTestFixture"-class to emulate Input. I set it up like this in my test-class:
    Code (csharp):
    1. protected readonly InputTestFixture Input = new();
    3. [SetUp]
    4. private void Setup()
    5. {
    6.     Input.Setup();
    7. }
    9. [TearDown]
    10. private void TearDown()
    11. {
    12.     Input.TearDown();
    13. }
    Afterwards I set the rightStick input in my UnityTest like this:

    Code (csharp):
    1. Gamepad gamepad = InputSystem.AddDevice<Gamepad>();
    2. Input.Set(gamepad.rightStick, Vector2.right);
    So far so good, my inputAction.performed-listener is called and everything works as expected.
    However if I now set the rightStick-input to another value in the same test, the update gets ignored and I don't get another performed event.

    After some experimentation I noticed, that it works consistently, if I set the rightStick input to first and THEN to my new value directly afterwards.

    Code (csharp):
    1. Input.Set(gamepad.rightStick,;
    2. Input.Set(gamepad.rightStick, Vector2.left);
    Is this intended behaviour? Is there a way to directly override the existing input value without zeroing it first?

    Thanks :)

    Unity Version 2021.3.4f1
    Input System Version 1.3.0
    Last edited: Jul 22, 2022
  2. leohilbert


    Nov 28, 2015
    Found the issue!
    "SetUp" and "TearDown" methods must be public. Both of my methods where private so neither Input.Setup(); nor Input.TearDown(); where called. This leads to the test Gamepads not being disposed correctly and this caused the inconsistent input behavior. I still have another issue when the "Reload Domain" settings is disabled, but I'll create another thread for that.