zoukankan      html  css  js  c++  java
  • Unity拖拽旋转2D物体

    /*************
    ** 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);
            }
    
    
        }
    }
  • 相关阅读:
    只能输入数字的文本框
    Ajax
    Crtl+Enter提交留言
    onkeydown onkeyup键盘事件
    面向对象基础
    JS鼠标拖拽
    博客收藏
    不错的按钮
    如何在你的java程序中注册系统级热键
    开源GIS系统
  • 原文地址:https://www.cnblogs.com/weiqiangwaideshijie/p/9626572.html
Copyright © 2011-2022 走看看