Calculate screen top and bottom postion

I need to figure this out for two reason and put it in two separate places for my game. Right now i have object spawning in hard code, I would like to spawn between top and bottom of the screen even with different screen sizes. The Second reason is that I need to stop the player from moving past the top and bottom of my camera view for all screen sizes. Can someone please help me I cannot find out how to do this anywhere.

Camera.main.ScreenToWorldPoint(new Vector3(screen.width, screen.height, 0);

is going to return where the top-right of your screen is


is going to return where the bottom left of the screen is

you can then get these coordinates however you’d like. hope this helped