How to change camera aspect ratio on different devices

How do I set the camera to scale properly with different screen sizes?

The camera scales it’s width automatically for you to match the desired output aspect ratio whether it is a render texture or to the screen.

However you can adjust other things in your scene to adapt to changes by using:

float aspect = (float)Screen.width / (float)Screen.height;

or if you are rendering to a render texture you might try:

float aspect = (float)Display.main.renderingWidth / (float)Display.main.renderingHeight