Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.EventSystems;
- public class Swipe : MonoBehaviour, IDragHandler {
- Vector2 delta;
- Quaternion rotationX;
- Quaternion rotationY;
- Quaternion originRotation;
- public GameObject Camera;
- public void OnDrag(PointerEventData eventData)
- {
- delta = eventData.delta;
- rotationX = Quaternion.AngleAxis(delta.x, Vector3.up);
- rotationY = Quaternion.AngleAxis(-delta.y, Vector3.right);
- originRotation = Camera.transform.rotation;
- }
- private void FixedUpdate()
- {
- Camera.transform.rotation = originRotation * rotationY * rotationX ;
- }
- }
Add Comment
Please, Sign In to add comment