- Home /
How to simulate mouse input?
Hi guys
I'm developing a videogame using the Kinect for Windows device. My question is simple: How can I simulate mouse input? I know the SendKeys class in C#, but I haven't figured out how to do it in Unity.
What's the best way to simulate mouse input from code?
Thanks in advance
Answer by hathol · May 21, 2012 at 09:30 PM
Try putting an additional layer of abstraction in between Input and game code. I usually create some sort of input manager that grabs the input and then either stores or forwards it to the relevant pieces of game logic. Makes things a little bit more complicated, but you can easily change or switch your complete input handling and even write tests for incoming input commands without ever touching the game logic. And of course you can just add code that randomly calls the "handleMouseInput" function :)
I suggest you take a look at that. You can have mouse click as events, thrown from one Update with if( Input.Etc ), or by whatever you want.