Hi,
I’m having a bug where all of my scripts (dozens) are not working, because I can’t drag and drop a gameobject in the ‘public GameObject’ variable. Can you guys help me out? I’ve had all my code checked and there are no errors in the console.
One of my scripts:
using UnityEngine;
using UnityEngine.SceneManagement;
public class Pause : MonoBehaviour
{
//I also tried:
//[SerializeField]
//public GameObject PauseMenu;
//Current code:
public GameObject PauseMenu;
//I also tried:
//[SerializeField]
//public GameObject ToMainMenu;
//Current code:
public GameObject ToMainMenu;
public static bool isPaused;
void Start()
{
PauseMenu.SetActive(false);
}
void Update()
{
if(Input.GetKeyDown(KeyCode.Escape))
{
if (isPaused)
{
Continue();
}
else
{
PauseGame();
}
}
}
private void PauseGame()
{
PauseMenu.SetActive(true);
Time.timeScale = Mathf.Epsilon;
isPaused = true;
}
private void Continue()
{
PauseMenu.SetActive(false);
Time.timeScale = 1f;
isPaused = false;
}
public void Quit()
{
Application.Quit();
}
public void ToMainMenuScene()
{
Time.timeScale = 1f;
SceneManager.LoadSceneAsync("Mainmenu");
isPaused = false;
}
}
Thanks in advance for the help!
