Finding the angle at which the edges of a camera shoot out

So, i have to zoom my camera out so the entire map is on the screen, and i can easily do the calculation of how far that has to be, if just i knew the angles in the camera, how do you find these, and is there a smarter way to do this?

The Angle Of View is a setting on the camera, directly accessible via: Camera.fieldOfView.

You’ll still have to do some further calculation based on the height/width ratio, but this will get you started.

For future reference, this is how i ended up solving the problem:

	float CalculateZ(){
		Ray bottomLeft = Camera.main.ScreenPointToRay (Vector2.zero);
		Ray topRight = Camera.main.ScreenPointToRay (new Vector2 (Screen.width, Screen.height));
		float tx = (LevelManager.self.gridWidth+2) * LevelManager.self.gridSize/(bottomLeft.direction.x - topRight.direction.x);
		float ty = (LevelManager.self.gridHeight+2) * LevelManager.self.gridSize/(bottomLeft.direction.y - topRight.direction.y);
		return (ty<tx?ty:tx)*bottomLeft.direction.z;
	}

the +2 is for the edges