/*************
** Company: DX
**SrtiptName:RotateImage
** Auth:    CW
** Des:      
** Ver.:     V1.0.0
*************/
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using System.Collections.Generic;
using Spine;
using Spine.Unity;
using UnityEngine.EventSystems;

namespace Kernal
{
   public class RotateImage : MonoBehaviour, IDragHandler
    {
        public void OnDrag(PointerEventData eventData)
        {
           
            SetDraggedRotation(eventData);
        }

        private void SetDraggedRotation(PointerEventData eventData)
        {
            Vector2 curSelfScreenPosition = RectTransformUtility.WorldToScreenPoint(eventData.pressEventCamera, transform.position);
            Vector2 directionTo = curSelfScreenPosition - eventData.position;
            Vector2 directionFrom = directionTo - eventData.delta;
            this.transform.rotation *= Quaternion.FromToRotation(directionTo, directionFrom);
        }


    }
}

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-31
  • 2021-10-06
  • 2021-10-16
  • 2021-10-26
  • 2021-10-10
猜你喜欢
  • 2022-12-23
  • 2021-08-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-15
相关资源
相似解决方案