I have the following code which should take a rect transform and align one of its corners exactly with the corner of a target rect transform (vertTargetTransform). When I run this code the rects are close to each other but misaligned... When I debug the xDiff and the yDiff they both say 0 even though the rects are clearly misaligned. I am doing this on a Screen Space - Camera canvas. Any ideas why this isnt working?
{
Vector3[] corners = new Vector3[4];
Vector3[] corners2 = new Vector3[4];
myTransform.GetWorldCorners(corners);
vertTargetTransform.GetWorldCorners(corners2);
corners[cornerToMatch] = canvasTransform.InverseTransformPoint(corners[cornerToMatch]);
corners2[cornerToMatch] = canvasTransform.InverseTransformPoint(corners2[cornerToMatch]);
float xDiff = corners[cornerToMatch].x - corners2[cornerToMatch].x;
float yDiff = corners[cornerToMatch].y - corners2[cornerToMatch].y;
Debug.Log(xDiff);
Debug.Log(yDiff);
Vector2 targetPosition = new Vector2(myTransform.anchoredPosition.x - xDiff, myTransform.anchoredPosition.y - yDiff);
LTDescr tween = LeanTween.move(myTransform, targetPosition, moveDuration);
tween.setEase(LeanTweenType.easeOutExpo);```
