Hi,
I need to position a button in runtime on a canvas at the same position of a different button from a different canvas. I have the both buttons references but I can’t seem to solve it.
Here is what I tried to do that doesn’t work:
//button1 and button2 are not in the same canvas. I want button2 to be on top of button1
Vector3 button1Viewport = camera1.WorldToViewportPoint(button1.transform.position);
Vector3 button2Position = gameObject.GetComponentInParent<Canvas>().worldCamera.ViewportToScreenPoint(button1Viewport);
button2.transform.position = button2Position;