From 5af824c419cf914897dae8d32a9a88b717cdfb53 Mon Sep 17 00:00:00 2001 From: Giannis Sakkas Date: Sun, 5 Feb 2023 19:32:25 +0200 Subject: [PATCH] Plane sound doesn't pause when pausing #45 fixed --- Assets/Scripts/Menu/PauseMenu.cs | 71 +++++++++++++++++--------------- 1 file changed, 37 insertions(+), 34 deletions(-) diff --git a/Assets/Scripts/Menu/PauseMenu.cs b/Assets/Scripts/Menu/PauseMenu.cs index 17979822..5a474fe9 100644 --- a/Assets/Scripts/Menu/PauseMenu.cs +++ b/Assets/Scripts/Menu/PauseMenu.cs @@ -3,38 +3,41 @@ public class PauseMenu : Menu { - - public Button quitButton; - - void Start() - { - quitButton.onClick.AddListener(GameController.ExitToMainMenu); - } - - - public void TogglePauseMenu() - { - if (IsOpen) - { - CloseMenu(); - } - else - { - OpenMenu(); - } - } - - - protected override void OnMenuOpened() - { - base.OnMenuOpened(); - GameController.SetPauseState(true); - } - - protected override void OnMenuClosed() - { - base.OnMenuClosed(); - GameController.SetPauseState(false); - } - + public Button quitButton; + [SerializeField] PlayerAudio playerAudio; + + void Start() + { + quitButton.onClick.AddListener(GameController.ExitToMainMenu); + } + + public void TogglePauseMenu() + { + if (IsOpen) + { + CloseMenu(); + } + else + { + OpenMenu(); + } + } + protected override void OnMenuOpened() + { + base.OnMenuOpened(); + ToggleSound(false); + GameController.SetPauseState(true); + } + + protected override void OnMenuClosed() + { + base.OnMenuClosed(); + ToggleSound(true); + GameController.SetPauseState(false); + } + + private void ToggleSound(bool toggleSound) + { + playerAudio.gameObject.SetActive(toggleSound); + } }