- Home /
How to check UI Element overlaps or not?
Hey, I have to check whether two image(UI) are overlapping or not. I already use rect.overlap(), output is really not acceptable, rect.contains also not work because both image are child of different parent. Is there any other way to calculate it. Currently I'm playing with RectTransformUtility.WorldToScreenPoint, this function give center of UI image so i can create new rect based on image center but this will not able to work for rotated image.
@SamuraiCoder I'm having the same exact issue. Any advance on this?
Answer by Liam-Lam · Mar 12, 2017 at 07:29 PM
Theres method calls RectTransform.getWorldCorners() . You can construct a Rect from that 4 corners (even your rectTransform rotating) . Then use Rect.overrlap func to check (but Rect is aabb so you have to use other structs to check overlap if your rectTransform is rotating). Hope this help @SamuraiCoder