- Home /
Question by
levi6706 · Feb 16, 2021 at 04:23 AM ·
inputinput.getbutton
2d RightClick new InputSystem Decect?
dose anyone know how to decect a right click on a object in 2d
inputs.Desktop.RightClick.performed += _ => RightClick();
}
void RightClick()
{
RaycastHit hit;
Ray ray = new Ray(Camera.main.transform.position, MousePos);
if (Physics.Raycast(ray, out hit))
{
Debug.Log(hit.collider);
}
}
Comment
Why don't you use OnPointerDown
and check the button
property of the eventdata?
https://docs.unity3d.com/2019.1/Documentation/ScriptReference/UI.Selectable.OnPointerDown.html
Your answer
![](https://koobas.hobune.stream/wayback/20220613025235im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Input not working at all! 1 Answer
Unable to check input action 0 Answers
Exact meaning of Input.GetButtonDown() 1 Answer
Is there a way to do different things depending on whether the button is being held or tapped? 2 Answers
Help In Making a SphereCast for 3D Tire! Working RayCast Script included! 0 Answers