Guest User

Untitled

a guest
Nov 24th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using UnityEngine.EventSystems;
  6.  
  7. public class Swipe : MonoBehaviour, IDragHandler {
  8. Vector2 delta;
  9. Quaternion rotationX;
  10. Quaternion rotationY;
  11. Quaternion originRotation;
  12. public GameObject Camera;
  13.  
  14. public void OnDrag(PointerEventData eventData)
  15. {
  16. delta = eventData.delta;
  17. rotationX = Quaternion.AngleAxis(delta.x, Vector3.up);
  18. rotationY = Quaternion.AngleAxis(-delta.y, Vector3.right);
  19. originRotation = Camera.transform.rotation;
  20. }
  21.  
  22. private void FixedUpdate()
  23. {
  24. Camera.transform.rotation = originRotation * rotationY * rotationX ;
  25.  
  26. }
  27.  
  28. }
Add Comment
Please, Sign In to add comment