private void OnMouseDown()
{
//Do something
}
What is the equivalent of this in the new input system?
private void OnMouseDown()
{
//Do something
}
What is the equivalent of this in the new input system?
Hi Chuubei,
I think you can achieve that by adding a new Press
interaction to your action, and setting the Trigger Behavior
to Press Only
.
Thanks for the response tanayg, I tried it out but then if I click the left button anywhere it will fire the code. Sorry I should’ve provided more details. Basically my intended behavior is to have a game object fire code only when the left mouse button is clicked when the mouse position is over the gameobject, not whenever the left button is clicked in general. Sorry, I hope this clears up what I’m trying to do.
@Chuubei : As it happened I opened a bug report with Unity to resolve this:
Input System and the OnMouse* events are currently incompatible with each other. I’m not sure if Unity intends to make them work, or just deprecate OnMouse*.
In the meantime, the best replacement I have is:
This is definitely a bunch more work than just calling OnMouseDown, so I’m hoping that Unity gets OnMouse* working with the Input System. However, this technique does give you a bit more control over what happens; you can detect exactly where on the object the mouse was clicked for example.
Thanks for sharing this, and I voted for that bug. This seems like pretty basic functionality that I’m surprised is not handled better by the new input system.
I was looking for the same thing. I posted a bit of code that uses InputSystem to return a Collider if you click on one at this link .