Scale/Stretch game scene to fit any device screen? Not referring to UI

Hi, I have been looking online and can’t seem to find a definitive answer on this.

Everything regarding the UI is fine, I just want to have my game scene fill the whole screen. Even if it loses graphic clarity and looks smooshed much like video game emulators allow. My game looks fine at 16:9 but begins to get a black border on the left and right side for different devices when I’d rather just stretch it out automatically. I realize I may need to just accept this and use a letterbox code, but like video game emulators I’d rather have the option to just have the game fill the whole screen instead of playing in it’s intended screen ratio leaving a bunch of empty space.

I’ll most likely use the letterbox code if stretching isn’t an option.

Thanks

but you neeed to realise that some devices like samsung s9 looks like this

 _______
|       |
|       |
|       |
|       |
|_______|

and in a tablet like this

 ____________
|            |
|            |
|            |
|            |
|____________|

you want the game to completly strech? you would not only lose quality, but a square would look like a rectangle, you need to find a game that those what you are trying to implement and copy or take it as a reference

I believe I got what I need, I retyped some code I found online a long time ago by a coder. I forgot I had it. I made adjustments regarding the “orthographicSize” and “aspect” that works for my game, here’s the code incase someone else is looking for what I was. If I am ever able to find who came up with the source for this I’ll give them credit. Working so far for me, hopefully it will keep working on different devices.

It’s a script you just need to attach to the “Main Camera”

public float orthographicSize = 5.3f;

public float aspect = 1.5f;

void Start()

{

    Camera.main.projectionMatrix = Matrix4x4.Ortho(-orthographicSize * aspect, orthographicSize * aspect, -orthographicSize, orthographicSize, GetComponent<Camera>().nearClipPlane, GetComponent<Camera>().farClipPlane);

}

Hi, You can find the solution at this tutorial “[SOLVED] Full tutorial: Build 2D game fit to any device screen size, resolution in Unity 2018” From youtube:

(By Vivu Standard).

Brgs,