Assignment for RMIT Mixed Reality in 2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
613 B

  1. namespace Oculus.Platform.Samples.VrHoops
  2. {
  3. using UnityEngine;
  4. // Helper class to attach to the MainCamera so it can be moved with the mouse while debugging
  5. // in 2D mode on a PC.
  6. public class Camera2DController : MonoBehaviour
  7. {
  8. void Update ()
  9. {
  10. if (Input.GetButton("Fire2"))
  11. {
  12. var v = Input.GetAxis("Mouse Y");
  13. var h = Input.GetAxis("Mouse X");
  14. transform.rotation *= Quaternion.AngleAxis(h, Vector3.up);
  15. transform.rotation *= Quaternion.AngleAxis(-v, Vector3.right);
  16. Vector3 eulers = transform.eulerAngles;
  17. eulers.z = 0;
  18. transform.eulerAngles = eulers;
  19. }
  20. }
  21. }
  22. }