How to Adjust Size of objects/Camera's size for different resolutions

I am working on a game in which few objects are instantiated outside the canvas, but while changing the screen’s resolution, it gives an absurd look to the game(objects inside and outside of the Canvas look weirdly placed), I tried the below code but is unable to give desired results for multiple resolutions,

if (Camera.main.aspect * Camera.main.orthographicSize !=9)
{
Camera.main.orthographicSize = 9 / Camera.main.aspect;
}

what should be the right approach, any leads will be appreciated.

Try setting the Camera.main.aspect to a value.

Camera.main.aspect = 1.3f;

But then you have to do this with the Canvas:

https://answers.unity.com/questions/1623091/ui-changes-wrong-when-screen-changes.html?childToView=1625115


I hope I helped you and understood everything correct