using System.Collections; using System.Collections.Generic; using UnityEngine; public class CheckCanvas : MonoBehaviour { // Start is called before the first frame update void Start() { } //������ת���Ƕ����� public int yMinLimit = -20; public int yMaxLimit = 80; //��ת�ٶ� public float xSpeed = 250.0f;//������ת�ٶ� public float ySpeed = 120.0f;//������ת�ٶ� //��ת�Ƕ� private float x = 0.0f; private float y = 0.0f; //���ű������� public float MinScale = 0.2f; public float MaxScale = 3.0f; //���ű��� private float scale = 1.0f; void Update() { if (Input.GetMouseButton(0)) { //Input.GetAxis("MouseX")��ȡ����ƶ���X��ľ��� x += Input.GetAxis("Mouse X") * xSpeed * 0.02f; y -= Input.GetAxis("Mouse Y") * ySpeed * 0.02f; y = ClampAngle(y, yMinLimit, yMaxLimit); //ŷ����ת��Ϊ��Ԫ�� Quaternion rotation = Quaternion.Euler(-y, -x, 0); transform.rotation = rotation; } if (Input.GetAxis("Mouse ScrollWheel") != 0) { scale += Input.GetAxis("Mouse ScrollWheel"); scale = Mathf.Clamp(scale, MinScale, MaxScale); transform.localScale = new Vector3(scale, scale, scale); } } //�Ƕȷ�Χֵ�� static float ClampAngle(float angle, float min, float max) { if (angle < -360) angle += 360; if (angle > 360) angle -= 360; return Mathf.Clamp(angle, min, max); } }