ive gone through unity answers and stackoverflow and tried many solutions and none of them worked.
Ive got a textmesh pro on my canvas and i want to tell if someone had clicked inside of the rect of that gameobject. ive tried using camera.main… converters and none work.
The textmesh pro object as you can see is a child so im guessing thats messing things up.
When i debug.log the rect the position makes no sense
I gave up on rect. Instead i created this below script. it all works and i think ill probably use this quite often.
public static Bounds setBounds(GameObject _item)
{
var min = Vector3.positiveInfinity;
var max = Vector3.negativeInfinity;
RectTransform RT = _item.GetComponent<RectTransform>();
var v = new Vector3[4];
RT.GetWorldCorners(v);
foreach (var vector3 in v)
{
min = Vector3.Min(min, vector3);
max = Vector3.Max(max, vector3);
}
Bounds bounds = new Bounds();
bounds.SetMinMax(min, max);
return bounds;
}