Advertisement
Deozaan

FindBorders

Mar 8th, 2013
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.59 KB | None | 0 0
  1. // borders
  2. private float _borderDown;
  3. private float _borderLeft;
  4. private float _borderUp;
  5. private float _borderRight;
  6.  
  7. private void _FindBorders() {
  8.     Camera cam = Camera.main; // cache camera
  9.     // get world coordinates of four corners of screen
  10.     Vector3 bottomLeft = cam.ScreenToWorldPoint(new Vector3(0, 0, Camera.main.transform.position.z * -1));
  11.     Vector3 topRight = cam.ScreenToWorldPoint(new Vector3(Screen.width, Screen.height, cam.transform.position.z * -1));
  12.     // get sides
  13.     _borderDown = bottomLeft.y;
  14.     _borderLeft = bottomLeft.x;
  15.     _borderUp = topRight.y;
  16.     _borderRight = topRight.x;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement