using System.Collections; using System.Collections.Generic; using UnityEngine; public class UIMultiScaleTool : MonoBehaviour, IPinchHandler { //该脚本由PinchZoom自动挂接 float scale = 1.0f; public float minScale; public float maxScale; private void OnEnable() { scale = 1.0f; } void Update() { float scrollWheelDelta = Input.GetAxis("Mouse ScrollWheel"); if (scrollWheelDelta > 0.01f || scrollWheelDelta < 0.01f)//鼠标滚轮 { scale += Input.GetAxis("Mouse ScrollWheel") * 0.5f; scale = Mathf.Clamp(scale, minScale, maxScale); transform.localScale = Vector3.one * scale; } } public void OnPinchStart() { } public void OnPinchEnd() { } public void OnPinchZoom(float delta) { _processPinch(delta); } private void _processPinch(float delta) { transform.localScale = Vector3.one * delta; } }