I have two object to control and I wanted to keep them at cameras view without adjusting the cameras size but the camera can move only in positive y-axis meaning ones it goes up it shouldn't move down but it's okay if one object gets out of bounds. Since its 2D the camera is Orthographic view.
If you can't make the camera view larger, then just set the camera's y position halfway between the two objects'
cameraY = (obj1Y +obj2Y) / 2
To make it stop at y = 0, use Mathf.Max:
cameraY = Mathf.Max(obj1Y + obj2Y, 0) / 2
This won't work if the camera can't display the two objects at once because they're too far apart