RectTransformUtility.RectangleContainsScreenPoint based on a circle
Hello guys,
I have a sniper scope lense which is a UIImage on a Canvas. Around it, I rotate images to indicate ennemies (game object - WorldToScreenPoint). If those ennemies are within the image rect of the scope lense, they disappear and if they're outside, they re-appear.
RectTransformUtility.RectangleContainsScreenPoint works pretty well but it based on a rect. My problem is that when indicators are at the corners of the rect, they're not hidden because it's a square and not a circle (Check circle C).
I used in the past one way which was to check the distance between the center of the screen and the enemy . Based on that distance, I was setting a rule saying that if the indicator is at 80% of that distance, it will disappear.
Since the layout was responsive I had inconsistent results, especially when you can rotate the screen.
Is there way to do something such as within the current bounds, draw a circle and check if that circle contains this enemy object?
Thanks a lot for your help!
Your answer
