fix: 音频系统代码清理 - 修复TouchPositionHandler多余} + 清理死代码

- TouchPositionHandler: 修复sed残留多余},改用PlayClipAtPoint
- PageController: StopBgMusic/HideAllPages分行,删除未调用的PlayWomanAudioSequence
This commit is contained in:
yangbear
2026-07-01 20:19:17 +08:00
parent b26a6e0fc7
commit 34287ca203
3 changed files with 4 additions and 26 deletions
@@ -38,7 +38,7 @@ public class TouchPositionHandler : MonoBehaviour
womanObject.transform.position = targetPosition.position;
womanObject.transform.rotation = targetPosition.rotation;
Debug.Log($"[TouchPosition] woman 移动到 {targetPosition.name}");
if (voiceClip != null) { var asrc = gameObject.AddComponent<AudioSource>(); asrc.PlayOneShot(voiceClip); Debug.Log("[TouchPosition] 播放语音: " + voiceClip.name); } }
if (voiceClip != null) { AudioSource.PlayClipAtPoint(voiceClip, transform.position); Debug.Log("[TouchPosition] 播放语音: " + voiceClip.name);
// 通知 StepManager 记录步骤
int stepIndex = transform.GetSiblingIndex() + 1;
+2 -24
View File
@@ -191,8 +191,6 @@ public class PageController : MonoBehaviour
var dialogue = GameObject.Find("DialogueBubble");
if (dialogue != null) dialogue.SetActive(false);
}
#endregion
#region
@@ -259,7 +257,8 @@ public class PageController : MonoBehaviour
Debug.Log($"PageController: GameManager 已设置 Mode=[{gm.CurrentMode}] Fixation=[{gm.CurrentFixationMethod}]");
// 隐藏所有UI面板,准备播放片头动画
StopBgMusic(); HideAllPages();
StopBgMusic();
HideAllPages();
// 找到 OpeningFlowController 播放片头动画
var openingFlow = FindObjectOfType<OpeningFlowController>();
@@ -318,23 +317,6 @@ public class PageController : MonoBehaviour
if (dialogue != null) dialogue.SetActive(true);
}
private System.Collections.IEnumerator PlayWomanAudioSequence()
{
if (_womanClips == null || _womanClips.Length == 0) yield break;
var voiceSource = gameObject.AddComponent<AudioSource>();
voiceSource.loop = false;
voiceSource.playOnAwake = false;
foreach (var clip in _womanClips)
{
if (clip == null) continue;
voiceSource.clip = clip;
voiceSource.Play();
Debug.Log($"PageController: 播放woman语音: {clip.name}");
yield return new WaitForSeconds(clip.length + 0.5f);
}
}
public void ReturnToHome()
{
Debug.Log("PageController: [ReturnToHome] 返回首页并重置场景");
@@ -364,13 +346,9 @@ public class PageController : MonoBehaviour
}
#endregion
[Header("=== 音频 ===")]
[SerializeField] private AudioClip _homeBgClip;
[SerializeField] private AudioClip _experimentBgClip;
[SerializeField] private AudioClip[] _womanClips;
private AudioSource _bgAudioSource;
}
+1 -1
View File
@@ -15,7 +15,7 @@
"com.unity.nuget.newtonsoft-json": "3.0.2",
"com.unity.test-framework": "1.1.31"
},
"hash": "85c101f5329ec1b0c6f70cba44614166dd78f53c"
"hash": "11836003a5e2ffcb7715ecec7e1fbb9d9cdb5bb8"
},
"com.unity.burst": {
"version": "1.8.21",