Hey, is there a way in Unity 4.6 how to detect whether Touch position is inside UI Rect like this?:
if (GUITexture.HitTest(Touch.Position)) return true;
I know there’s a RectTransform Component but due to Anchors, it’s coordinates arent in pixels from bottom-left corner. So I Tried something like this:
RectTransform SRTrans = this.GetComponent<RectTransform>();
this.TouchAreaRect = new Rect(
this.transform.position.x - SRTrans.rect.width / 2,
this.transform.position.y - SRTrans.rect.height / 2,
this.transform.position.x + SRTrans.rect.width / 2,
this.transform.position.y + SRTrans.rect.height / 2
);
This code is working for one of my UI Images, but it’s not working properly for other ones so is there a better solution like GUI Texture had a HitTest Method?