模型缩放 旋转的脚本 C#版本 上个项目写的

来源:互联网 发布:centos 7如何搭建VPN 编辑:程序博客网 时间:2024/06/06 02:24
using UnityEngine;
using System.Collections;public class ModelRotation : MonoBehaviour {public float speed = 20.0f;private float flag;private float flag_y;private bool bRotate;// Use this for initializationvoid Start () {bRotate = false;}// Update is called once per framevoid Update () {flag = Input.GetAxis("Mouse X");flag_y = Input.GetAxis("Mouse Y");if(flag > 0 && flag_y == 0){if (Input.GetKey("left")){this.transform.Rotate(Vector3.up*Time.deltaTime*-speed);}if (Input.GetKey("right")){this.transform.Rotate(Vector3.up*Time.deltaTime*speed);}}}void OnGUI(){if(Event.current.type == EventType.MouseDrag){if(bRotate && gameObject.rigidbody.angularVelocity.x == 0){//transform.Rotate(new Vector3(0, -Input.GetAxis("Mouse X"), 0)*speed);transform.Rotate(new Vector3(0,-Input.GetAxis("Mouse X"),0)*speed);}else if(bRotate && gameObject.rigidbody.angularVelocity.z == 0){transform.Rotate(new Vector3(0, 0, -Input.GetAxis("Mouse Y"))*speed);Debug.Log("rotate v");}}}void OnMouseEnter(){clickObj scriptObj = (clickObj)gameObject.GetComponent<clickObj>();bool bFlag = scriptObj.bDrag;if(!bFlag)bRotate = true;}void OnMouseExit(){bRotate = false;}}
using UnityEngine;using System.Collections;public class ModelRotation : MonoBehaviour {public float speed = 20.0f;private float flag;private float flag_y;private bool bRotate;// Use this for initializationvoid Start () {bRotate = false;}// Update is called once per framevoid Update () {flag = Input.GetAxis("Mouse X");flag_y = Input.GetAxis("Mouse Y");if(flag > 0 && flag_y == 0){if (Input.GetKey("left")){this.transform.Rotate(Vector3.up*Time.deltaTime*-speed);}if (Input.GetKey("right")){this.transform.Rotate(Vector3.up*Time.deltaTime*speed);}}}void OnGUI(){if(Event.current.type == EventType.MouseDrag){if(bRotate && gameObject.rigidbody.angularVelocity.x == 0){//transform.Rotate(new Vector3(0, -Input.GetAxis("Mouse X"), 0)*speed);transform.Rotate(new Vector3(0,-Input.GetAxis("Mouse X"),0)*speed);}else if(bRotate && gameObject.rigidbody.angularVelocity.z == 0){transform.Rotate(new Vector3(0, 0, -Input.GetAxis("Mouse Y"))*speed);Debug.Log("rotate v");}}}void OnMouseEnter(){clickObj scriptObj = (clickObj)gameObject.GetComponent<clickObj>();bool bFlag = scriptObj.bDrag;if(!bFlag)bRotate = true;}void OnMouseExit(){bRotate = false;}}


	
				
		
原创粉丝点击