Changing Orthographic size according to resolution

I know this question was already asked, but I didn’t find the correct answer for my situation, so be patient with me please :frowning:

I’m making a 2D puzzle game with a board, and I would like to set up my Orthographic camera size according to the resolution, aspect ratio, and board size.

The objective is to get a full screen board with all mobile devices.

Can someone help me?

Assuming a square board, centered on the camera of ‘boardSize’ the code would be:

if (Screen.width < Screen.height) {
    Camera.main.orthographicSize = boardSize / 2 * Screen.height / Screen.width;

You only have to make a change if the width is narrower than the height. For a given orthographicSize, the camera will see the same height in world units no matter what the resolution.