2D - OnMouseDown not working despite having a collider
Hello, I have a 2D project in Unity 5.3.8. I have an object and I want to have something happen when it is clicked. I attached a Box Collider 2D component and put the OnMouseDown() function in a script attached to it. However, nothing happens when it is clicked, no matter what I put inside the OnMouseDown() function.
I did some research and found that the layer order of sprites could cause an issue. However, this object's SpriteRenderer is in the frontmost layer and is the only object in that layer.
The other thing that I can think might cause an issue is that I have a UI, so maybe the canvas is blocking the click somehow. I looked at the canvas object, and saw it has a component called Graphic Raycaster. It has a "Blocking Objects" option, but this is set to "None" so I don't think that's the issue.
I have a panel within the canvas, and I looked at that. It has an Image component, and one of the options is "Raycast Target". Well, I don't want to click the panel, just things on it, so I tried turning that off, but it didn't change anything.
Any ideas on what the issue could be?
Your answer
Follow this Question
Related Questions
Co ordinates of 2D object/image,Get Co ordinates covered by Object 0 Answers
How to order clickable gameObjects that overlap? (2D) 1 Answer
Sprite 2d passes through the ground 0 Answers
[SOLVED] Problems creating a Sprite through script 0 Answers
How to disable rendering of one of the colors from the image ? 0 Answers