Resize Camera

Hello all ,

I have this problem where i want the screen to scale according to the size of the mobile screen .

I have previously worked with this code :

 private const float MIN_CAMERA_WIDTH = 23.6112f;

    void Awake()
        Camera mainCamera = Camera.main;
        float cameraWidth = mainCamera.orthographicSize * mainCamera.aspect * 2f;
        if (cameraWidth < MIN_CAMERA_WIDTH)
            mainCamera.orthographicSize = (MIN_CAMERA_WIDTH * 0.5f)/ mainCamera.aspect;

But now i have a perspective camera and not orthographic
How can I achieve desired effect?

Thanks for all in advance

hey ;
this is not the way ! ;
if u want to do this for sprites :

first do every thin on a special resolution (like 16:9) ;

then attach a script to your camera and in the start method call this code :

  void Start()
        GetComponent<Camera>().aspect = 16 / 9f;


this way in every resolutions the camera and sprite will be scaled as u like;

for the ui its a little different ;