Constraining an orthographic camera to an isometric world

I am using Unity3D, and I am building an isometric world by rotating a plane on the Y axis by 4.205 units.

I am using an orthographic camera. I want to constrain the camera so that the viewport never shows the area outside of the world (in green).

alt text

  1. How can I calculate the corner
    points of my rotated plane in screen
    coordinates, represented by green?
  2. How do I stop the camera from
    scrolling to prevent it from showing
    the area outside the world,
    represented by gray?

Where you move your camera in script, you want to check if it is within X or Y distance from the sides/top of the world. If it is, re-adjust its movement so it takes it to those limits and no further.

If your world is always the same size, that makes it easy; just have four public floats in your move script representing the ‘extremities’ of the camera movement. E.g.

public float leftEdge = -100;
public float rightEdge = 100;
public float topEdge = 75;
public float bottomEdge = -75;

void Move() {
Vector3 newPosition = GetNewPosition(); // or however you're getting the new position.

if (newPosition.x < leftEdge) { newPosition.x = leftEdge; }
if (newPosition.x > rightEdge) { newPosition.x = rightEdge; }
if (newPosition.y < bottomEdge) { newPosition.y = bottomEdge; }
if (newPosition.y > topEdge) { newPosition.y = topEdge; }

camera.transform.position = newPosition;

}

There are more elegant ways to do this, and with some arithmetic you could mathematically derive the extremities based on the aspect ratio and zoom level, but I chose to suggest the easy to implement option.