- Home /
How do I Keep game objects on the screen proportional While building games for different aspect ratios?
When I change screen size and ratios inside of unity, certain objects on the screen overlap and or gets really displaced. Is there any simple solution to fixing this? Someone briefly told me about Screen.width and Screen.height but the explanation was not that good. I just need to make sure the game works on all screens its played on. Any suggestions that a beginner would be able to grasp and understand?
The idea behind "Screen.width and Screen.height" was that you could just check the screen size and adjust the scale of the objects accordingly so that they fit on the screen as you want
knowing the context(2d, 3d) would probably help, but a simple example would be if you'd like you object to be 1/2 of the screen size.. so you'd do..
gameObject.transform.localScale = new Vector3(Screen.width/2, 0, Screen.height/2);
for 3D you probably would need to do a bit more calculations or move back the camera so that all the objects are in the view
Your answer
Follow this Question
Related Questions
Vertex shader coordinates in clip space 1 Answer
Input.mouseposition affected by game scene size 2 Answers
Why does OnMouseDown work in Free Aspect, but NOT in 1024 x 768? 2 Answers
Camera Viewport Rect Not Work in iPhone 5? 0 Answers
OrthographicSize on Android changes from Start to Update? 0 Answers