简体   繁体   English

在 Unity 中:当游戏通过停止/等于 0 的时间刻度暂停时,音量不会调整

[英]In Unity: Volume does not adjust while game is paused via timescale being stopped / equal to 0

I have a settings menu in my game, where I have different audio (background music, dialogue, etc) where I can adjust the volume manually.我的游戏中有一个设置菜单,其中有不同的音频(背景音乐、对话等),我可以在其中手动调节音量。

This happens during pause, so you can hear the volume and set it to your preference.这发生在暂停期间,因此您可以听到音量并根据自己的喜好进行设置。

This was working fine, then one day, it stopped, and I haven't been able to figure out why.这工作正常,然后有一天,它停止了,我一直无法弄清楚为什么。

All I know is that the volume of the audioSource DOES update, but the "actual" audio stays the same volume "until" you unpause (set the timescale back to 1) then it changes to match what the variable in the AudioSource says.我所知道的是 audioSource 的音量会更新,但“实际”音频会保持相同的音量“直到”您取消暂停(将时间刻度设置回 1)然后它会更改以匹配 AudioSource 中的变量所说的内容。

To emphasise, the value "does" update, but the real sound stays the same until you unpause.需要强调的是,该值“确实”更新了,但在您取消暂停之前,真实声音保持不变。 How can I hear the sound change while the game is paused?如何在游戏暂停时听到声音变化?

The fact this seemed to work before, suggests an update or change in setting may have broken it, but may also be able to fix it?这似乎以前有效的事实表明更新或更改设置可能会破坏它,但也可以修复它? Otherwise I just have to not use timescale for pausing, or move the volume control settings outside of the pause mechanics否则我只需要不使用时间刻度来暂停,或者将音量控制设置移到暂停机制之外

Thanks in advance提前致谢

This may be caused by the audio mixers updateMode being set to AudioMixerUpdateMode.Normal .这可能是由于音频混合器updateMode被设置为AudioMixerUpdateMode.Normal的。

Changing the updateMode to AudioMixerUpdateMode.UnscaledTime will ignore Time.timeScale and update the audio mixer in real time.updateMode更改为AudioMixerUpdateMode.UnscaledTime将忽略Time.timeScale并实时更新混音器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM