Hi,
I’m currently writing a Unit Test where I have this action:
It’s just a Vector2Control with a Composite with One Modifier, where the Modifier is the left mouse button and the binding is the mouse position.
Then, I’ve the following test for that:
public class InputReaderSOTests : InputTestFixture
{
[Test]
public void DoesExecuteClickEventWhenEnabled()
{
var mouse = InputSystem.AddDevice<Mouse>();
var inputReader = ScriptableObject.CreateInstance<InputReaderSO>();
inputReader.EnablePlayerControls();
var clickedVector = Vector2.zero;
inputReader.Click += position => clickedVector = position;
// Works
/*InputSystem.QueueStateEvent(mouse, new MouseState() { position = new Vector2(1337, 1337)}.WithButton(MouseButton.Left ));
InputSystem.Update();*/
// Does not work
/*Set(mouse.position, new Vector2(1337, 1337), queueEventOnly: false);
Click(mouse.leftButton);*/
clickedVector.Should().Be(new Vector2(1337, 1337));
}
}
In the documentation there’s a entry about using Set/Click/Press etc. for setting the state.
As you can see in the example, I set the mouse.position and then I click the left mouse button. However, the test reports that the mouse was not clicked on that position.
However, if I use the other method above using InputSystem.QueueStateEvent and InputSystem.Update it works as expected.
I feel that it also should work with set Set and Click methods. Any idea what I’m missing?
Thanks!