CUI_CameraController.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using UnityEngine;
  2. using System.Collections;
  3. namespace CurvedUI
  4. {
  5. public class CUI_CameraController : MonoBehaviour
  6. {
  7. public static CUI_CameraController instance;
  8. #pragma warning disable 0649
  9. [SerializeField]
  10. Transform CameraObject;
  11. [SerializeField]
  12. float rotationMargin = 25;
  13. [SerializeField]
  14. bool runInEditorOnly = true;
  15. #pragma warning restore 0649
  16. // Use this for initialization
  17. void Awake()
  18. {
  19. instance = this;
  20. }
  21. #if UNITY_EDITOR
  22. // Update is called once per frame
  23. void Update()
  24. {
  25. if((Application.isEditor || !runInEditorOnly) && !UnityEngine.XR.XRSettings.enabled)
  26. {
  27. CameraObject.localEulerAngles = new Vector3(Input.mousePosition.y.Remap(0, Screen.height, rotationMargin, -rotationMargin),
  28. Input.mousePosition.x.Remap(0, Screen.width, -rotationMargin, rotationMargin),
  29. 0);
  30. }
  31. }
  32. #endif
  33. }
  34. }