Pause Menu issue with mouse

Hey guys, just wondering how i can get my mouse to stay active while in the pause menu, it pops up fine, but then when any buttons are click the Cursor disappears, Have tried with and without 'Cursor.visable = true" and same outcome, have tried looking in Scripting API for Cursor.lockState, but cannot find any coding in relation to C#

Here is the coding for my pausemenu

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityStandardAssets.Characters.FirstPerson;

public class PauseMenu : MonoBehaviour {

    public GameObject Player;
    GameObject PauseCanvas;
    bool paused;


	// Use this for initialization
	void Start () {
        PauseCanvas = GameObject.Find("PauseMenu");
    }
	
	// Update is called once per frame
	void Update () {
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            paused = !paused;
        }

        if (paused)
        {
            //GameObject.Find("Player").GetComponent<FirstPersonController>().enabled = false;
            PauseCanvas.SetActive(true);
            Time.timeScale = 0;
            //Cursor.visible = true;
        } else if (!paused)
        {
            //GameObject.Find("Player").GetComponent<FirstPersonController>().enabled = true;
            PauseCanvas.SetActive(false);
            Time.timeScale = 1;
            //Cursor.visible = false;
        }
	}

    public void Resume()
    {
        paused = false;
    }

    public void Quit()
    {
        SceneManager.LoadScene("MainMenu");
    }
}

Also upon loading the ‘MainMenu’ from the Quit() void, my main camera animation on that scene fails to start, it loads but just sits at the very start without animating.

Have provided a Video to assist in providing the right help.
Youtube Video Link

@crazyKnight
@MikeNewall
@alejandro-unity

‘@’ Tagged due to all posts being moderated upon post

bump due to 22hr wait time on moderation approval

What kind of buttons lead to disappearing mouse (UI buttons)? Do they have their own scripts? During the gameplay the cursor is disabled? If yes, do you disable it in another script?

Any clues as to how this can be achieved?

1 Answer

1

Are you using the RigidbodyFirstPersonController or probably just the MouseLook script component somewhere else?

The MouseLook locks and hides the mouse cursor on release of the left mouse button. To avoid this, call SetCursorLock(false) on the MouseLook.

PS: As for the animation problem: You need to ensure that the Time.timeScale is set back to 1 when leaving the menu, no matter in what way. If you want to keep the timeScale at zero, you can still play animations by setting them to use unscaledTime.

i am using a RigidbodyFirstPersonController from the standard assets. and thank you for the the animation tip, so should i set the timescale back to 1 within the Quit void? or on a start function in the MainMenu Scene?

Thank you so much for this answere. I literally searched 3 hours to fix my "after escape-menu cursor show up" - Bug and it was the MouseLook. :-)