I am a beginner to unity and I need to know how to detect when the mouse has went down
My script is parented to the camera (Because it is a camera script) and I need to know when the mouse button goes down so I can start to move the camera.
I also need to know when it moves, or goes up.
CodePudding user response:
You should use the New Input System for this, it's got a little bit of a learning curve but has exactly what you are looking for as it is entierly based around input events.
There is a good explination here. You'll want to use the performed
event of an input action, which is a regular event you can subscribe your functions to.
The performed
event will corespond to whatever you set the action to be triggered by, for example the press down of a button if you set it so, or could be the press and release of a button.
So like:
cameraMoveAction.performed =
(_) =>
{
// move the camera
};
CodePudding user response:
You could specify, when exactly mouse button click should be detected. The most logical case is using UI. So here you are.