- Home /
How to place a 3D object in the exact same space as 2D object on Screen?
I have a UI element that stretches appropriately to the screen. Inside that UI element I have this black square just for reference. I am trying to place a 3D object in world space on the same spot that this black square is. I am having trouble trying to do so.
I get the position of the UI element with this following code:
Vector3[] corners = new Vector3[4];
rect.GetWorldCorners(corners);
Vector3 topLeft = Camera.main.ScreenToWorldPoint(corners[1]);
I get the top left corner of the UI object but when I do this, I am getting a negative value for these even though the position is on the screen and shouldnt be negative. As far as I am aware, GetWorldCorners starts in the bottom left and works clockwise so [1] should be top left.
Negative values coming from GetWorldCorners
Image of the UI element. Black square is just a placeholder to get the size that I am looking for with the 3D object
Your answer

Follow this Question
Related Questions
UI - Best method for Scene UI elements 1 Answer
Healthbar follow with screenspace-camera canvas 0 Answers
Interact whit 3D UI 1 Answer
Convert 2D Camera to 3D for my Gameplay UI Setup 0 Answers
(New UI) 3D objects as buttons? 1 Answer