我正在尝试使用缩放限制在我的游戏中放大和缩小。我正在使用此代码进行滚动和捏合,但我不知道如何限制缩放距离(minzoomlimit 和 maxzoomlimit)。我的意思是,当玩家想要放大时,他可以放大一定距离,而当他想缩小时,他可以放大一定距离。
这是我用来滚动和捏合的代码。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class ScrollAndPinch : MonoBehaviour
{
#if UNITY_IOS || UNITY_ANDROID
public Camera Camera;
public bool Rotate;
protected Plane Plane;
public float perspectiveZoomSpeed = 0.5f; // The rate of change of the field of view in perspective mode.
public float orthoZoomSpeed = 0.5f;
public Transform Map;
float distance;
float MaxDistance = 37063.57f; /*= new Vector3(-3724.8f, 34576.9f, -4562.5f);*/
float MinDistance = 123302.2f; /*= new Vector3(-18149.0f, 180315.6f, -73023.5f);*/
private void Awake() …Run Code Online (Sandbox Code Playgroud)