- Home /
Most efficient way to get the current screen width of 1 world point.
I have a tile-based project and 1 world point is a tile.
I could grab the screen width of an object that is present that happens to be a tile wide. This seems convoluted based on this answer: https://answers.unity.com/questions/352738/gameobject-width-in-screen-space.html (Might be an easier way.)
Is there a better way? Seems like something that would be in the Unity API somewhere. I just can't find it.
Answer by tonytopper · Dec 30, 2020 at 11:40 PM
Alright, able to answer my own question. This seems pretty efficient.
Camera.main.WorldToScreenPoint(Vector2.right).x - Camera.main.WorldToScreenPoint(Vector2.zero).x
Your answer
Follow this Question
Related Questions
Dragging panel(prefab) from screen space canvas to world space canvas and scaling to fit 0 Answers
Scale Gameobject with defined size in pixels 2 Answers
World space and UI space 3 Answers
Convert world to screenspace for screenshot of particular object 1 Answer
World BoxCollider size to Match Screen Space UI image size 1 Answer