Use 2d Polygon Collider to detect OnMouseEnter on UI
I have a UI image that is a triangle, and while the image is a box of course I need to only detect OnMouseEnter on the triangular area. However I cannot get this to work. I have tried adding a PolygonCollider2D to my Image and set it to isTrigger = true, but I cannot get it to log anything! Any help is appreciated!
I made the collider a bit bigger so you can see it
My code is attached to the Image with the PolygonCollider2D and right now is very simple, but is not logging anything:
void OnMouseEnter()
{
Debug.Log("Collider Entered!");
}
Well, I have been able to solve this with just colliders. I created a panel with a box collider 2d and rigid body 2d, scripted it to follow the cursor, then just detected the collision. This doesn't really answer my question (solving the issue with On$$anonymous$$ouseEnter), but it solves my problem.
Answer by starrtennis · Aug 08, 2019 at 11:55 PM
Is the code you provided located within the Radial Button script? Is the script where this code resides even attached to the game object which owns the polygon collider?
Your answer
