问题
As you know, OnMouseDown work on mouse click but its run on every collider. My simple question is can i restrict OnMouseDown event to run on some specfic colliders not all collider as I am using some collider for trigger. Those some collider which i am using for trigger don't want to hit through onMouseDown.
回答1:
You can try raycasting from the mouseposition and get the collider hit. This is what I would advice. This would do the trick: https://docs.unity3d.com/ScriptReference/Input-mousePosition.html Just do the raycasting and test for the collider hit.
If you need more adivce, let me know.
My personal adivce would be to replace the mouseDownEvent with the Input.getMouseButtonDown(0) and place it inside Update.
来源:https://stackoverflow.com/questions/42465363/restricting-onmousedown-event-on-specific-collides