- Home /
Vector3 to float[ScreenToWorldPoint]
I have this problem with gui elements and screen sizes. If I position my GUI label(using Screen.width/height) according to the screen size of the unity game preview and export it to an android package and view it shifts to the left and for smaller screen size it appears way beyond the place I wanted it to be. I have designed the scenes in my game using ScreenToWorld points where it converts the screen to world co-ordinates and it works really well with all android screen sizes.
So here is my question
How can I convert the Vector3 value to float and use it inside the GUI Label?
GUI.Label(Rect(vector3valueX,vector3valueY , 800, 800), dispScore, customStyle);
I'm unsure of your question. To convert to from world to GUI, you can convert first from world to screen then convert from world to GUI.
var screenPos = Camera.main.WorldToScreenPoint(worldPos);
var guiPos = screenPos;
guiPos.y = Screen.height - guiPos.y;