Hey there,
so i try to place a Plane as a GUI element So i placed a second Cam. Set the settingt to ortographic and rendered my Plane. Everthing ist good except that the plane and my UI are not synced in Screenspace when i change the Screen.width / height. I have no idee how to archive this. How can i force the plane to be everytime rendered at the same Screen X / Y Position ?
Need i to adjust Cam settings or did i need to change the plane position to a specific screen Position ? What is the simplest / solid way to archive this ?
Thanks & Greetings
Lukas
There are four coordinates systems in Unity, World, Screen, Viewport and GUI. I’m going to assume you have are using GUI and Rects to output your GUI elements. You can position a 3D world object at a GUI coordinate by 1) Converting that coordinate to a Screen coordinate, and then 2) converting the Screen coordinate to a World coordinate. Note World coordinates are in 3D space, so you have to specify the distance in front of the camera when you do the Screen to World conversion. So if we had a GUI coordinate at (200, 300):
var v3GUI = Vector3(200,300,0);
var v3Screen = GUIUtility.GUIToScreenPoint(v3GUI);
v3Screen.z = 10; // Picking 10 units in front of the camera
var v3World = Camera.main.ScreenToWorldPoint(v3Screen);