Advertisement
Guest User

Untitled

a guest
Dec 7th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class MouseTest : MonoBehaviour
  6. {
  7. float moveSum;
  8. float scrollSum;
  9.  
  10. void Start ()
  11. {
  12. Camera.main.orthographic = true;
  13. Camera.main.transform.position = Vector3.up * 10;
  14. Camera.main.transform.LookAt (Vector3.zero);
  15. }
  16.  
  17. void Update ()
  18. {
  19. transform.position = new Vector3 (Mathf.Cos (Time.time), 0, Mathf.Sin (Time.time)) * 4.5f;
  20.  
  21. if (Input.GetMouseButtonDown (0))
  22. moveSum = 0;
  23.  
  24. if (Input.GetMouseButtonDown (1))
  25. scrollSum = 0;
  26.  
  27. if (Input.GetMouseButton (0))
  28. moveSum += new Vector2 (Input.GetAxis ("Mouse X"), Input.GetAxis ("Mouse Y")).magnitude;
  29.  
  30. scrollSum += Mathf.Abs (Input.GetAxis ("Mouse ScrollWheel"));
  31. }
  32.  
  33. void OnGUI ()
  34. {
  35. GUI.Label (new Rect (Screen.width / 2, Screen.height / 2, 100, 100), "" + moveSum + "\n" + scrollSum);
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement