From dd3460dae19ee1e35c48dc8ed06ad49226e5b112 Mon Sep 17 00:00:00 2001 From: shenjianxing <”315615051@qq.com“> Date: Wed, 26 Mar 2025 16:27:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8F=8C=E5=87=BB=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E9=95=9C=E5=A4=B4=E8=B7=B3=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scripts/Item/Show3DCamera.cs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/Assets/Scripts/Item/Show3DCamera.cs b/Assets/Scripts/Item/Show3DCamera.cs index bf70c00b..d5456f95 100644 --- a/Assets/Scripts/Item/Show3DCamera.cs +++ b/Assets/Scripts/Item/Show3DCamera.cs @@ -27,7 +27,7 @@ public class Show3DCamera : MonoBehaviour public RenderTexture texture; public bool lockMove = false; - + private const float DRAG_THRESHOLD = 1f; // קֵ private Vector2 mouseDownPosition; // ¼갴ʱλ @@ -162,10 +162,17 @@ public class Show3DCamera : MonoBehaviour mouseDownPosition = Input.mousePosition; } - // ޸ĺתų״̬ - if (!isZooming && (isTouching ? (Input.GetTouch(0).phase == TouchPhase.Moved) : Input.GetMouseButton(0))) + bool shouldRotate = false; + if (Input.GetMouseButton(0)) { - // ƳжֱӦ + // ʹвק + float dragDistance = Vector2.Distance(Input.mousePosition, mouseDownPosition); + shouldRotate = dragDistance > DRAG_THRESHOLD; + } + // ޸ĺתų״̬ + if (!isZooming && (isTouching ? (Input.GetTouch(0).phase == TouchPhase.Moved) : shouldRotate)) + { + RotateCamera(); } @@ -322,7 +329,6 @@ public class Show3DCamera : MonoBehaviour /// public void FocusObj(Vector3 target, float distance = 1f, float moveTime = -1) { - // ǰһλãΪCubeĿλ // ԸҪ Vector3 cameraPos = target - transform.forward * distance; @@ -398,6 +404,9 @@ public class Show3DCamera : MonoBehaviour { deltaX = Input.GetAxis("Mouse X") * 10; // ԭ deltaY = Input.GetAxis("Mouse Y") * 10; + // ۼƶֵʱЧ + if (Mathf.Abs(deltaX) < DRAG_THRESHOLD && Mathf.Abs(deltaY) < DRAG_THRESHOLD) + return; } // ӦDPIţؼ