Hi everyone,
I want to test my left click on a MonoBehaviour, it works in the Scene but not in the Unit test.
Here is the code :
public class PlayableElement : MonoBehaviour, IPointerClickHandler
{
void IPointerClickHandler.OnPointerClick(PointerEventData eventData)
{
Debug.Log("Mouse down");
}
}
And the non working test (it compiles but no Debug.Log so far…)
The element is at the position 0 0.
public class PlayableElementTest : InputTestFixture
{
[UnityTest]
public IEnumerator should_catch_click_correctly()
{
// Setup
yield return EditorSceneManager.LoadSceneAsyncInPlayMode("Assets/Tests/Scenes/click.unity", new LoadSceneParameters(LoadSceneMode.Single));
var mouse = InputSystem.AddDevice<Mouse>();
Move(mouse.position, Vector2.zero);
Click(mouse.leftButton);
yield return new WaitForSeconds(1f);
}
}
Thanks for your help !