- Home /
Returning to main menu
After i die in my game, I return to main menu BUT the cursor doesn't appear.
I have added a hide cursor script that hides the cursor during game play but it seems to be applied to the menu as well
Hide cursor: public PlayerHealth playerHealth; public float restartDelay = 5f;
 Animator anim;
 float restartTimer;
 void Awake()
 {
     anim = GetComponent<Animator>();
 }
 void Update () 
 {
     if (playerHealth.currentHealth <= 0) 
     {
         anim.SetTrigger("GameOver");
         restartTimer += Time.deltaTime;
         if (restartTimer >= restartDelay) 
         {
             SceneManager.LoadScene ("Menu");
         }
     }
 }
Any suggestions on how to turn it off when the player is in Menu?
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by SamuelRoos · Nov 21, 2018 at 04:43 PM
You could do by just adding these two lines either after, or before the LoadScene() call:
 Cursor.visible = true;
 Cursor.lockState = CursorLockMode.None;
Or if you want to be much cooler, you could add a function which is called everytime a scene has been loaded, check if it's the main menu scene and if yes, enable & unlock the cursor like this:
 private void Awake () 
 {
      SceneManager.sceneLoaded += OnSceneLoaded;
 }
 
  private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
  {
      if (scene.name == "Menu") 
      {
            Cursor.visible = true;
            Cursor.lockState = CursorLockMode.None;
      }
  }
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                