[SOLVED]Unity UI panel - RectTransform.rect

Hello I am now facing this issue and I have no idea what’s going on…
The console output is print(GetComponent().rect) of the panel…

Any ideas on how to fix this? I want to use GetComponent().rect.Contains(mousepos) for my Inventory system… :frowning:

Try this: Unity - Scripting API: RectTransformUtility.RectangleContainsScreenPoint

pass ‘null’ as the camera if you’re using screen space overlay.

1 Like

I wanted to add that if this is for selecting or dropping inventory items into “slots”, I would suggest that you use the IDragHandler, IDropHandler, and other pointer interfaces to help you. :slight_smile:

1 Like

Damn, you’re the man! Thank you very much, this is the answer I needed! :slight_smile:

You’re welcome. :slight_smile:

1 Like