From 9deb4a68e1a434880129ffb18f7ca52476b64e0c Mon Sep 17 00:00:00 2001 From: yangbear Date: Thu, 2 Jul 2026 16:42:43 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20ping=E4=B8=A4=E9=98=B6=E6=AE=B5=E7=82=B9?= =?UTF-8?q?=E5=87=BB=E2=80=94=E5=85=A8=E9=83=A84=E4=B8=AA=E9=A6=96?= =?UTF-8?q?=E6=AC=A1=E7=82=B9=E5=87=BB=E5=90=8E=E6=89=8D=E5=85=81=E8=AE=B8?= =?UTF-8?q?=E7=AC=AC=E4=BA=8C=E5=87=BB=E6=98=BE=E7=A4=BAchanrao?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 阶段0(_firstClickCount<4): 依次首次点击显示ping模型,激活下个ping 阶段1(_firstClickCount==4): 第二击显示chanrao并隐藏ping UndoSecondClick同步恢复_firstClickCount --- .../Scripts/Interaction/PingClickHandler.cs | 37 +++++++++---------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/Assets/Scripts/Interaction/PingClickHandler.cs b/Assets/Scripts/Interaction/PingClickHandler.cs index 846a1ed..55437d3 100644 --- a/Assets/Scripts/Interaction/PingClickHandler.cs +++ b/Assets/Scripts/Interaction/PingClickHandler.cs @@ -14,6 +14,7 @@ public class PingClickHandler : MonoBehaviour private MeshRenderer _meshRenderer; private LineRenderer _outlineRenderer; + private static int _firstClickCount = 0; private bool _clickedOnce; void Start() @@ -75,39 +76,34 @@ public class PingClickHandler : MonoBehaviour void OnMouseDown() { - if (!_clickedOnce) + // 阶段 0:4个ping依次首次点击(只显示模型) + if (_firstClickCount < 4) { - // 第一次点击:停止闪烁,显示模型 + if (_clickedOnce) return; _clickedOnce = true; + _firstClickCount++; StopAllCoroutines(); if (_meshRenderer != null) _meshRenderer.enabled = true; if (_outlineRenderer != null) _outlineRenderer.enabled = true; - Debug.Log($"[PingClick] {name} 第一次点击,模型显示"); + // 激活下个 ping + if (nextPing != null) { nextPing.SetActive(true); Debug.Log($"[PingClick] {name} → {nextPing.name} 激活"); } + Debug.Log($"[PingClick] {name} 第1击 (model显示, {_firstClickCount}/4)"); + var sm = FindObjectOfType(); + if (sm != null) sm.RecordPingStep(pingIndex, false); } + // 阶段 1:4个全部首次点击后,第二击显示chanrao else { - // 第二次点击:显示 chanrao,隐藏自己,激活下个 ping - if (chanraoObject != null) - { - chanraoObject.SetActive(true); - Debug.Log($"[PingClick] {chanraoObject.name} 已显示"); - } - + if (!_clickedOnce) return; + if (chanraoObject != null) { chanraoObject.SetActive(true); Debug.Log($"[PingClick] {chanraoObject.name} 已显示"); } StopAllCoroutines(); if (_meshRenderer != null) _meshRenderer.enabled = false; if (_outlineRenderer != null) _outlineRenderer.enabled = false; gameObject.SetActive(false); - - if (nextPing != null) - { - nextPing.SetActive(true); - Debug.Log($"[PingClick] {name} → {nextPing.name} 已激活"); - } + Debug.Log($"[PingClick] {name} 第2击 (chanrao显示)"); + var sm = FindObjectOfType(); + if (sm != null) sm.RecordPingStep(pingIndex, true); } - - // 通知 StepManager - var sm = FindObjectOfType(); - if (sm != null) sm.RecordPingStep(pingIndex, _clickedOnce); } /// 上一步撤销:恢复到first-click状态 @@ -115,6 +111,7 @@ public class PingClickHandler : MonoBehaviour { if (!_clickedOnce) return; _clickedOnce = false; + _firstClickCount--; gameObject.SetActive(true); if (_meshRenderer != null) _meshRenderer.enabled = false; StopAllCoroutines();