91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

[unity3d]鼠標拖動and旋轉縮放

發布時間:2020-02-26 12:03:43 來源:網絡 閱讀:430 作者:蓬萊仙羽 欄目:游戲開發
using UnityEngine; using System.Collections;  public class mouseRotateAndScale : MonoBehaviour { 	GameObject car; 	//public GameObject light; 	Vector2 p1, p2;//用來記錄鼠標的位置,以便計算旋轉幅度 	 // 鼠標中間鍵     int MouseWheelSensitivity = 5;     int MouseZoomMin = 18;     int MouseZoomMax = 90;     float normalDistance = 60; 	// Use this for initialization 	void Start () { 		car = GameObject.Find("benchi"); 		 	} 	 	// Update is called once per frame 	void Update () { 		 //旋轉         if (Input.GetMouseButtonDown(0))         {             p1 = new Vector2(Input.mousePosition.x, Input.mousePosition.y);//鼠標左鍵按下時記錄鼠標位置p1                      }         if (Input.GetMouseButton(0))         {             p2 = new Vector2(Input.mousePosition.x, Input.mousePosition.y);//鼠標左鍵拖動時記錄鼠標位置p2             if (transform.position.y >= 20 && transform.position.y <= 130)  //控制在20-130之內             {                   float dx = p2.x - p1.x;                                  float dy = (float)0.6 * (p2.y - p1.y);                 //鼠標上下移動                 transform.Translate(-dy * Vector3.up * Time.deltaTime);                 transform.RotateAround(car.transform.position, Vector3.up, dx * Time.deltaTime);             }             else if (transform.position.y < 20 && p2.y < p1.y)             {                 float dx = p2.x - p1.x;                  float dy = (float)0.6 * (p2.y - p1.y);                 //鼠標上下移動                 transform.Translate(-dy * Vector3.up * Time.deltaTime);                 transform.RotateAround(car.transform.position, Vector3.up, dx * Time.deltaTime);             }             else if (transform.position.y > 130 && p2.y > p1.y)             {                 float dx = p2.x - p1.x;                  float dy = (float)0.6 * (p2.y - p1.y);                 //鼠標上下移動                 transform.Translate(-dy * Vector3.up * Time.deltaTime);                 transform.RotateAround(car.transform.position, Vector3.up, dx * Time.deltaTime);             }             //下面開始旋轉,僅在水平方向上進行旋轉                                                    //else if (transform.position.y < 20)             //{             //    transform.position.y = 20.1f;             //}             //else if (transform.position.y > 130)             //{             //    transform.position.y = 129.9f;             //}             //light.transform.RotateAround(car.transform.position, Vector3.up, dx * Time.deltaTime);         }           //鼠標滾輪控制場景大小         // 如果按住滑輪         if (Input.GetAxis("Mouse ScrollWheel") > 0)         {             Debug.Log(1);             Debug.Log(Input.GetAxis("Mouse ScrollWheel"));                         if (normalDistance >= MouseZoomMin && normalDistance <= MouseZoomMax)             {                 normalDistance -= Input.GetAxis("Mouse ScrollWheel") * MouseWheelSensitivity;             }              if (normalDistance < MouseZoomMin)             {                 normalDistance = MouseZoomMin;             }             if (normalDistance > MouseZoomMax)             {                 normalDistance = MouseZoomMax;             }            // transform.Translate(transform.forward * normalDistance);             transform.camera.fieldOfView = normalDistance;                       }          //后滾         else if (Input.GetAxis("Mouse ScrollWheel") < 0)         {             Debug.Log(-1);             if (normalDistance >= MouseZoomMin && normalDistance <= MouseZoomMax)             {                 normalDistance -= Input.GetAxis("Mouse ScrollWheel") * MouseWheelSensitivity;             }              if (normalDistance < MouseZoomMin)             {                 normalDistance = MouseZoomMin;             }             if (normalDistance > MouseZoomMax)             {                 normalDistance = MouseZoomMax;             }            // transform.Translate(-transform.forward * normalDistance);             transform.camera.fieldOfView = normalDistance;         } 	} } 

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

错那县| 昭苏县| 邵阳市| 黑水县| 周至县| 民和| 东乌| 东乡县| 漠河县| 武城县| 固镇县| 鄂托克旗| 永登县| 台北市| 新田县| 蒙自县| 凤冈县| 双鸭山市| 皮山县| 长丰县| 礼泉县| 唐山市| 始兴县| 铜川市| 凌海市| 宁都县| 甘孜县| 巴彦淖尔市| 凯里市| 凤翔县| 鄄城县| 健康| 乌恰县| 博客| 云浮市| 利辛县| 婺源县| 玉环县| 尚志市| 晋州市| 丰宁|