40 lines
1005 B
C#
40 lines
1005 B
C#
using Sirenix.OdinInspector;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class UIMultiScaleTool : MonoBehaviour, IPinchHandler
|
|
{
|
|
[InfoBox("该脚本由PinchZoom自动挂接")]
|
|
|
|
float scale = 1.0f;
|
|
|
|
public float minScale;
|
|
public float maxScale;
|
|
|
|
private void OnEnable()
|
|
{
|
|
scale = 1.0f;
|
|
}
|
|
void Update()
|
|
{
|
|
#if UNITY_EDITOR
|
|
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;
|
|
}
|
|
#endif
|
|
}
|
|
|
|
public void OnPinchStart() { }
|
|
public void OnPinchEnd() { }
|
|
public void OnPinchZoom(float delta)
|
|
{
|
|
scale = Mathf.Clamp(delta, minScale, maxScale);
|
|
transform.localScale = Vector3.one * scale;
|
|
}
|
|
}
|