拖拽旋转
using UnityEngine;
using System.Collections;
using UnityEngine.EventSystems;
public class RotateImage : MonoBehaviour, IDragHandler
{
public void OnDrag(PointerEventData eventData)
{
//拖拽旋转图片
SetDraggedRotation(eventData);
}
private void SetDraggedRotation(PointerEventData eventData)
{
Vector2 curScreenPosition = RectTransformUtility.WorldToScreenPoint(eventData.pressEventCamera, transform.position);
Vector2 directionTo = curScreenPosition - eventData.position;
Vector2 directionFrom = directionTo - eventData.delta;
this.transform.rotation *= Quaternion.FromToRotation(directionTo, directionFrom);
}
}拖拽移动
using UnityEngine;
using System.Collections;
using UnityEngine.EventSystems;
public class MoveImage : MonoBehav