diff --git a/osu.Game/Screens/Play/PauseOverlay.cs b/osu.Game/Screens/Play/PauseOverlay.cs index 11f62939fb..18d17c1317 100644 --- a/osu.Game/Screens/Play/PauseOverlay.cs +++ b/osu.Game/Screens/Play/PauseOverlay.cs @@ -34,9 +34,9 @@ namespace osu.Game.Screens.Play OnResume?.Invoke(); }; - private IBindable? windowActive; + private readonly IBindable windowActive = new Bindable(true); - private float targetVolume => windowActive?.Value != false && State.Value == Visibility.Visible ? 1.0f : 0; + private float targetVolume => windowActive.Value && State.Value == Visibility.Visible ? 1.0f : 0; [BackgroundDependencyLoader] private void load(GameHost? host) @@ -48,10 +48,15 @@ namespace osu.Game.Screens.Play }); if (host != null) - { - windowActive = host.IsActive.GetBoundCopy(); - windowActive.BindValueChanged(_ => Schedule(() => pauseLoop.VolumeTo(targetVolume, 1000, Easing.Out))); - } + windowActive.BindTo(host.IsActive); + } + + protected override void LoadComplete() + { + base.LoadComplete(); + + // Schedule required because host.IsActive doesn't seem to always run on the update thread. + windowActive.BindValueChanged(_ => Schedule(() => pauseLoop.VolumeTo(targetVolume, 1000, Easing.Out))); } public void StopAllSamples()