- Home /
Sprite size as a fraction of Viewport size
I want to find out the sprite size as a fraction of viewport size.
What I want to do is layout a set of tiles in a frame that is on the screen. The frame is another sprite, which is smaller than the whole game screen. To layout the tiles I am using:
childTransform.position = Camera.main.ViewportToWorldPoint(new Vector3(xNormalizedTilePosition, yNormalizedTilePosition, 1));
As you can see, it will be good to normalize the tile positions into a fraction of how big the frame is (i.e. the frame takes up 50% of the screen's x size, and 60% of the screen's y size).
Is there a way to do this?
Your answer
Follow this Question
Related Questions
MissingComponentException after changing Animator component. 1 Answer
Avoid/Minimize Sprites extrapolation in 2D while camera changes size 0 Answers
Crosshair Not Parallel To camera 1 Answer
Black Trail Rendering in 2D game 1 Answer
How do i mask a sprite so that it is only visible on another moving sprite? 0 Answers