123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class CheckCanvas : MonoBehaviour
- {
-
- 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))
- {
-
- 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);
- }
- }
|