I have a problem. For my game I want to make a pause menu with two buttons, home and resume. The resume button, I think you know what it does, but the problem is with the home button. In the code area the name of the scene to which the home button should lead(StartMenu), appears in red. Obviously if I click on “home”, it does nothing. What can I do? I checked if the name of the scene is spelled correctly, it is, I checked if the scene is active, it is. The code I am using is:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class PauseMenu : MonoBehaviour
{
public static bool IsGamePaused = false;
[SerializeField] GameObject pausepanel;
private void Update()
{
// ESCAPE PAUSE BUTTON
if (Input.GetKeyDown(KeyCode.Escape))
{
if (IsGamePaused)
{
Resume();
}
else
{
Pause();
}
}
}
//RESUME BUTTON
public void Resume()
{
pausepanel.SetActive(false);
Time.timeScale = 1;
IsGamePaused = false;
}
//PAUSE BUTTON
public void Pause()
{
pausepanel.SetActive(true);
Time.timeScale = 0;
IsGamePaused = true;
}
// HOME BUTTON
public void LoadMenu()
{
Time.timeScale = 1;
IsGamePaused = false;
SceneManager.LoadScene("StartMenu");
}
}