I have one problem : when I pause the game , the audio pauses too , but I created a “go back to menu” button , it goes to the main menu but when i hit start again and the game starts running , my audio is dead , i can not hear anything so if anyone knows what should I do please tell me , thanks in advance!
Here is my code : using UnityEngine;
using UnityEngine.SceneManagement;
public class pausemenu : MonoBehaviour
{
public GameObject pauseMenu;
public bool isPaused;
void Start()
{
pauseMenu.SetActive(false);
}
// Update is called once per frame
void Update()
{
if(Input.GetKeyDown(KeyCode.Escape))
{
if(isPaused)
{
ResumeGame();
}
else
{
PauseGame();
}
}
}
public void PauseGame()
{
pauseMenu.SetActive(true);
Time.timeScale = 0f;
isPaused = true;
AudioListener.pause = true;
}
public void ResumeGame()
{
pauseMenu.SetActive(false);
Time.timeScale = 1f;
isPaused = false;
AudioListener.pause = false;
}
public void GoToMainMenu()
{
Time.timeScale = 1f;
SceneManager.LoadScene("menu1");
}
public void QuitTheGame()
{
Application.Quit();
}
}