Cant Use Mouse in my Main Menu after scene Change

basically I start off my game with the main menu (scene 0), all the code and buttons work and I’m able to click play and start my game in the next scene (scene 1). However the problem is that when its game over, I am transported back to the previous menu scene and I am unable to click on any buttons and unable to play again. any tips? my first time posting a thread and I’m pretty new to coding.

this is the game over script

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class GameOver : MonoBehaviour
{
   

    private void OnTriggerEnter(Collider other)
    {
        SceneManager.LoadScene(0);

    }
}

and this is my menu script with the play button

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class MainMenu : MonoBehaviour
{
    public void PlayGame ()
    {
        SceneManager.LoadScene(1);
    }

    public void QuitGame()
    {
        Debug.Log("QUIT!");
        Application.Quit();
    }
}

A UI needs an EventSystem to have functional interaction, is that being lost somewhere between scene loads?

1 Like

Do you lock the cursor in your game? Do you make your cursor invisible? is it an FPS game?

Before loading the menu, you have to reset the cursor visibility and locked state OR set it to visible and unlocked in the start method of your menu.

Also don’t fortget to set Time.timeScale back to “1”.

1 Like