Advertisement
Guest User

Untitled

a guest
Apr 20th, 2015
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. void handleCameraMove()
  2. {
  3. Rect screenRect = new Rect(0,0, Screen.width, Screen.height);
  4. if (!screenRect.Contains (Input.mousePosition)) {
  5. return;
  6. }
  7.  
  8. panningRect = new Rect (scrollSize, scrollSize, Screen.width - (scrollSize * 2f), Screen.height - (scrollSize * 2f));
  9.  
  10. Vector3 direction = Vector3.zero;
  11.  
  12. if (mouseX > panningRect.xMax || Input.GetKey(KeyCode.RightArrow)) {
  13. direction = direction + Vector3.right;
  14. }
  15.  
  16. if (mouseX < panningRect.xMin || Input.GetKey(KeyCode.LeftArrow)) {
  17. direction = direction + Vector3.left;
  18. }
  19.  
  20. if (mouseY < panningRect.yMin || Input.GetKey(KeyCode.DownArrow)) {
  21. direction = direction + Vector3.back;
  22. }
  23.  
  24. if (mouseY > panningRect.yMax || Input.GetKey(KeyCode.UpArrow)) {
  25. direction = direction + Vector3.forward;
  26. }
  27.  
  28. transform.Translate(direction.normalized * panSpeed * Time.deltaTime, Space.World);
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement