fix: bg音乐缓入+语音打断+代码碎片清理
- PlayHomeBg/PlayExperimentBg 增加 FadeInBg 缓入协程(1.5s) - TouchPositionHandler 使用静态共享 AudioSource 避免语音重叠 - 清理 PageController 中因多次编辑产生的代码碎片和括号混乱
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user