鼠标控制模型旋转

发布日期:2017-02-08 12:20:06来源:小小灵爱李婷
[导读]usingUnityEngineusingSystem.CollectionspublicclassRotaRole:MonoBehaviour{   publicVector3mousePos   IEnumeratorOnMouseDown   {       mousePos=Inp...

using UnityEngine;
using System.Collections;
public class RotaRole : 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;
        }
    }
}

回到
顶部