Black bars, how to add them?

Hi,
My game uses and orthographic, pixel perfect camera with resolution locked to 16/9.
This is the camera script:

using UnityEngine;
using System.Collections;

public class CameraSize : MonoBehaviour {
 
    public float desiredOrth;

    void Start(){
        float actualOrth = 100000;
        int i = 1;
        while(actualOrth > desiredOrth){
            actualOrth = Screen.height/(2*i);
                i++;
        }
        Camera.main.orthographicSize = actualOrth;
    }
}

My problem is that when the game is running on a screen that has a resolution different to 16/9, instead of adding black borders on the sides ( i believe they are called pillarbox bars and letterbox bars) the game screen stretches.

I want to prevent stretching whilst keeping the resolution lock and a pixel perfect camera.

Any advice on how to fix this problem would be appreciated.
Thanks.

Please use code tags when asking a question involving code :slight_smile: