Question by
yafrolushka · Feb 05, 2020 at 11:00 AM ·
camerawebglcoordinatesscreentoworldpoint
ScreenToWorldPoint for WebGL build and Editor return different values
Hello everyone! I have a Game window with resolution 1280x720. Script, that translates screen corner coordinates to world and print it to console:
var cam = Camera.main;
Vector2 LeftBottom = cam.ScreenToWorldPoint(Vector3.zero);
Vector2 RightTop = cam.ScreenToWorldPoint(new Vector3(Screen.width, Screen.height, 0));
Debug.Log($"Left bottom: {LeftBottom}");
Debug.Log($"Right top: {RightTop}");
Then, i check output in the editor and webgl build and its different!
As i understand editor consider screen aspect ratio, but the webgl build not for some reason. So why this happens and how I can get values in webgl similar to editor?
editor.png
(121.7 kB)
build.png
(510.0 kB)
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612222755im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Get the screen coordinates of the object in the projected FishEye image -1 Answers
Show Text where user clicks in a panel,Show text where User clicks 0 Answers
Keep GameObject size in pixels on screen by zooming camera 0 Answers
Shadow rendering distance HTML5 1 Answer
camera zoom/moveing and object position 0 Answers