Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void handleCameraMove()
- {
- Rect screenRect = new Rect(0,0, Screen.width, Screen.height);
- if (!screenRect.Contains (Input.mousePosition)) {
- return;
- }
- panningRect = new Rect (scrollSize, scrollSize, Screen.width - (scrollSize * 2f), Screen.height - (scrollSize * 2f));
- Vector3 direction = Vector3.zero;
- if (mouseX > panningRect.xMax || Input.GetKey(KeyCode.RightArrow)) {
- direction = direction + Vector3.right;
- }
- if (mouseX < panningRect.xMin || Input.GetKey(KeyCode.LeftArrow)) {
- direction = direction + Vector3.left;
- }
- if (mouseY < panningRect.yMin || Input.GetKey(KeyCode.DownArrow)) {
- direction = direction + Vector3.back;
- }
- if (mouseY > panningRect.yMax || Input.GetKey(KeyCode.UpArrow)) {
- direction = direction + Vector3.forward;
- }
- transform.Translate(direction.normalized * panSpeed * Time.deltaTime, Space.World);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement