- Home /
This post has been wikified, any user with enough reputation can edit it.
Question by
Slowbad · Mar 04, 2014 at 07:54 PM ·
inputinput.mousepositioninput.getmousebuttondown
Simulate mouse input
I've downloaded the Unity Test Tools and I'm trying to figure out how to simulate moving the mouse around and clicking as a form of integration testing. The game's core update function will handle a player's mouse input and I want to make sure I've wired everything together using the automated tools.
void Update() {
Ray ray = Camera.main.ScreenPointToWorld(Input.mousePosition);
RaycastHit hit;
if(Physics.Raycast(ray, out hit)){
//Handle input
}
}
So above is your boilerplate for interacting with the mouse every frame. The API says that Input.mousePosition is read only. Is there a round about way I can edit this and maybe even have Input.mouseButtonDown(0) return true so I can test events automatically?
Comment