Fix master volume not applied on startup
The mixer's start snapshot overwrites exposed params set before the first frame, so the BeforeSceneLoad SetFloat was discarded. Re-apply the saved volume after one frame (Awaitable.NextFrameAsync). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
46b8d532b6
commit
38b9369051
1 file changed
+6
-3
@@ -72,11 +72,14 @@ public static class MasterVolume
|
||||
Debug.LogWarning($"[MasterVolume] Exposed parameter '{ExposedParam}' not found on the AudioMixer.");
|
||||
}
|
||||
|
||||
// Push the saved level before any scene audio starts. SetFloat overrides the exposed parameter
|
||||
// permanently (until ClearFloat), so the start snapshot's authored value is superseded.
|
||||
// Push the saved level at startup. SetFloat before the first frame is discarded when the mixer
|
||||
// activates its start snapshot (known Unity behavior: exposed params set in Awake/BeforeSceneLoad
|
||||
// get reset), so apply immediately for best effort and again one frame later to make it stick.
|
||||
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
|
||||
private static void ApplyOnStartup()
|
||||
private static async void ApplyOnStartup()
|
||||
{
|
||||
Apply(Volume);
|
||||
await Awaitable.NextFrameAsync();
|
||||
Apply(Volume);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user