- Home /
How to lock the game screen to certain dimensions?
So I want my game view to ONLY show the background, none of the blue. Is there anyway it will automatically do this no matter what screen size it's on? Or if someone can send me a tutorial with this information would be awesome too.
I'm not sure, I want the camera to only be on the background, but not sure how to adjust the camera's xy's lol can't figure it out
Well I'm developing this for an itouch device, is there anyway I can just make it automatically change the screen width and height depending on the device but still keep all the content in between the screen dimensions?
Answer by iamvishnusankar · Feb 15, 2014 at 02:28 AM
If you're bored of reading too much stuff and want some visual explanation. Check this out. This has pretty much everything you want
Answer by erick_weil · Feb 15, 2014 at 02:43 AM
if your bakcground is set OnGui() will only need to especify the width of background as Screen.widht and the height at Screen.height
but if your background is a plane gameObject:
the height is always the same, only manually drag the camera to look exactly at the top and botton corners
but.. the width is variable, you need or to resize the plane(as a child of the camera) in x-axis using a simple count: place a object at the top of the plane, and one at the botton; one at left and one at right.
#pragma strict var top : GameObject; var bottom : GameObject; var left :GameObject; var right : GameObject; var height : float; var width : float; var planewidth : float; function Start () { top = GameObject.Find("top").gameObject; bottom = GameObject.Find("bottom").gameObject; left = GameObject.Find("left").gameObject; right = GameObject.Find("right").gameObject; height = (top.transform.position - bottom.transform.position).y; planewidth = (left.transform.position - right.transform.position).x; width = (Screen.width*height)/Screen.height; transform.localScale.x = planewidth/width; } function Update () { height = (top.transform.position - bottom.transform.position).y; width = (Screen.width*height)/Screen.height; planewidth = (left.transform.position - right.transform.position).x; transform.localScale.x = width/planewidth; }
I don't understand what you're saying, is there anyway to just set the height and width of the orthographic camera to match that of an iPhone screen? And if not why not?
you are using a orthografic camera, lol, sorry for this. I tryed to scale the plane gameobject to match at the borders of an perspective camera.
Your answer
![](https://koobas.hobune.stream/wayback/20220613133536im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Resizable GUI box how to? 1 Answer
Window info not updating when moved 0 Answers
Objects to fit on the screen 2 Answers
Make an Orthographic Camera FIT in the screen, not FILL it. 0 Answers
How to make game fit all screen Size and Resolutions 1 Answer