From 38b9369051a52cc6cea17b66d6d8bb9a7f87956e Mon Sep 17 00:00:00 2001 From: MelekTaus Moribundus Date: Sat, 11 Jul 2026 13:06:44 +0200 Subject: [PATCH] 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 --- Assets/Scripts/Helper/MasterVolume.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Assets/Scripts/Helper/MasterVolume.cs b/Assets/Scripts/Helper/MasterVolume.cs index cfcc61c..7950c3f 100644 --- a/Assets/Scripts/Helper/MasterVolume.cs +++ b/Assets/Scripts/Helper/MasterVolume.cs @@ -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); } }