unity 3d中简单巧妙的实现拖动鼠标旋转物体

using UnityEngine;
using System.Collections;

public class BaseRotate : MonoBehaviour {

    public Vector3 mousePos;

    IEnumerator OnMouseDown()
    {

        mousePos = Input.mousePosition;

        while (Input.GetMouseButton(0))
        {
            Vector3 offset = mousePos - Input.mousePosition;

            transform.Rotate(Vector3.up * offset.x, Space.World);    
            transform.Rotate(Vector3.right*offset.y,Space.World);

            mousePos=Input.mousePosition;
            yield return null;
        }
    }
}

展开阅读全文

没有更多推荐了,返回首页