From 3a831408017c6acbbf8a506d184b6965e0cf4385 Mon Sep 17 00:00:00 2001 From: yangbear Date: Wed, 1 Jul 2026 21:07:01 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=87=8D=E5=BB=BATouchPositionHandler.c?= =?UTF-8?q?s=E4=BF=AE=E5=A4=8D=E6=8B=AC=E5=8F=B7=E6=B7=B7=E4=B9=B1?= =?UTF-8?q?=E7=BC=96=E8=AF=91=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Interaction/TouchPositionHandler.cs | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/Assets/Scripts/Interaction/TouchPositionHandler.cs b/Assets/Scripts/Interaction/TouchPositionHandler.cs index 18f2899..ea838f5 100644 --- a/Assets/Scripts/Interaction/TouchPositionHandler.cs +++ b/Assets/Scripts/Interaction/TouchPositionHandler.cs @@ -19,12 +19,19 @@ public class TouchPositionHandler : MonoBehaviour StartCoroutine(BlinkMesh()); } + private void OnEnable() + { + _meshRenderer = GetComponent(); + if (_meshRenderer != null) _meshRenderer.enabled = true; + StopAllCoroutines(); + StartCoroutine(BlinkMesh()); + } + private System.Collections.IEnumerator BlinkMesh() { while (true) { - if (_meshRenderer != null) - _meshRenderer.enabled = !_meshRenderer.enabled; + if (_meshRenderer != null) _meshRenderer.enabled = !_meshRenderer.enabled; yield return new WaitForSeconds(0.4f); } } @@ -38,9 +45,14 @@ public class TouchPositionHandler : MonoBehaviour womanObject.transform.position = targetPosition.position; womanObject.transform.rotation = targetPosition.rotation; Debug.Log($"[TouchPosition] woman 移动到 {targetPosition.name}"); - if (voiceClip != null) { AudioSource.PlayClipAtPoint(voiceClip, transform.position); Debug.Log("[TouchPosition] 播放语音: " + voiceClip.name); + } + + if (voiceClip != null) + { + AudioSource.PlayClipAtPoint(voiceClip, transform.position); + Debug.Log($"[TouchPosition] 播放语音: {voiceClip.name}"); + } - // 通知 StepManager 记录步骤 int stepIndex = transform.GetSiblingIndex() + 1; var sm = FindObjectOfType(); if (sm != null) sm.RecordWomanStep(stepIndex); @@ -55,13 +67,4 @@ public class TouchPositionHandler : MonoBehaviour Debug.Log($"[TouchPosition] {name} → {nextTouchObject.name} 显示"); } } - - - private void OnEnable() - { - _meshRenderer = GetComponent(); - if (_meshRenderer != null) _meshRenderer.enabled = true; - StopAllCoroutines(); - StartCoroutine(BlinkMesh()); - } }