Hello everyone, so I’m having this issue with my main menu system.
So when I start the game and I’m in my main menu, everything works fine and stuff.
Then if I load into a level and start playing it also works fine.
But then I hit escape (I have code that would load the main menu scene when I hit escape) to go back to the main menu and when I try to click anything, the mouse locks to the center of the screen.
Please help!
Main Menu script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class MainMenu : MonoBehaviour
{
//Load Scene
public void Play()
{
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
}
//Quit Game
public void Quit()
{
Application.Quit();
Debug.Log("The Player has Quit the game");
}
}
Change scene by key or whatever script:
using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;
public class Menu: MonoBehaviour {
void Update(){
if(Input.GetKeyDown(KeyCode.Escape)){
SceneManager.LoadScene("Main Menu");
}
}
}