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()); - } }