I’m working on a game that I want to be the same resolution as a Game Boy Advance game, being only 240x160. Now obviously that would be annoying to play on a computer, so I want to scale the game up. What I want is to limit the camera to seeing 240x160 pixels, but when the game runs, be able to scale up the screen while keeping the ratio (even if I can’t keep the ratio perfect, that’s okay as long as I can limit the camera but can still scale the game in a window). How would I go about limiting the camera? I’m pretty sure the scaling will be handled by Unity when the game is run.
Add a black frame to the UI using solid panels to your desired size, ensure you setup anchors to the frame position, whatever you see inside the frame will be the same on every device and platform.
or
setting
Screen.SetResolution(240, 180, true);
not sure how it will look, true being fullscreen
I found this script from my old project. Maybe this will work
what this script does is crop the camera rect.
Just attach this script to the camera.
public float aspect_ratio_x=9f;
public float aspect_ratio_y=16f;
void Start() {
fixaspect ();
}
void fixaspect(){
float targetaspect = aspect_ratio_x / aspect_ratio_y;
float windowaspect = (float)Screen.width / (float)Screen.height;
float scaleheight = windowaspect / targetaspect;
if(scaleheight>=1f) {// add pillarbox
float scalewidth = 1.0f / scaleheight;
Rect rect = GetComponent<Camera>().rect;
rect.width = scalewidth;
rect.height = 1.0f;
rect.x = (1.0f - scalewidth) / 2.0f;
rect.y = 0;
GetComponent<Camera>().rect = rect;
}
else {
GetComponent<Camera>().rect=new Rect(0,0,1,1);
}
//Camera.main.aspect = aspect_ratio_x / aspect_ratio_y;
}