fix: bg音乐缓入+语音打断+代码碎片清理

- PlayHomeBg/PlayExperimentBg 增加 FadeInBg 缓入协程(1.5s)
- TouchPositionHandler 使用静态共享 AudioSource 避免语音重叠
- 清理 PageController 中因多次编辑产生的代码碎片和括号混乱
This commit is contained in:
yangbear
2026-07-01 21:18:34 +08:00
parent 3a83140801
commit f68e675022
2 changed files with 63 additions and 34 deletions
@@ -49,7 +49,7 @@ public class TouchPositionHandler : MonoBehaviour
if (voiceClip != null)
{
AudioSource.PlayClipAtPoint(voiceClip, transform.position);
PlaySharedVoice();
Debug.Log($"[TouchPosition] 播放语音: {voiceClip.name}");
}
@@ -67,4 +67,20 @@ public class TouchPositionHandler : MonoBehaviour
Debug.Log($"[TouchPosition] {name} → {nextTouchObject.name} 显示");
}
}
private static AudioSource _sharedVoice;
private void PlaySharedVoice()
{
if (voiceClip == null) return;
if (_sharedVoice == null)
{
var go = GameObject.Find("[Managers]");
if (go != null) _sharedVoice = go.AddComponent<AudioSource>();
else { var g = new GameObject("SharedVoice"); _sharedVoice = g.AddComponent<AudioSource>(); }
}
_sharedVoice.Stop();
_sharedVoice.clip = voiceClip;
_sharedVoice.Play();
}
}