亚洲激情专区-91九色丨porny丨老师-久久久久久久女国产乱让韩-国产精品午夜小视频观看

溫馨提示×

溫馨提示×

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

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

[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

柳林县| 无锡市| 陆河县| 枣强县| 临海市| 巢湖市| 铁岭县| 乌鲁木齐县| 太仆寺旗| 贵定县| 苏尼特左旗| 隆化县| 合川市| 杭锦旗| 德化县| 海原县| 博野县| 胶南市| 英德市| 五指山市| 绥棱县| 南昌县| 吉首市| 灵山县| 大埔县| 芦溪县| 玉田县| 陈巴尔虎旗| 永康市| 新和县| 泾川县| 中方县| 扬中市| 墨江| 锦屏县| 京山县| 威海市| 景东| 阳信县| 夏河县| 益阳市|