The question is answered, right answer was accepted
How to disable mouse lock script when returning to main menu
I need to disable the mouse lock script when I return to the main menu so the cursor is unlocked and visible.
Here is the pause menu script i'm using
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class PauseMenu : MonoBehaviour {
public static bool GameIsPaused = false;
public GameObject pauseMenuUI;
// Update is called once per frame
void Update () {
if (Input.GetKeyDown(KeyCode.Escape))
{
if (GameIsPaused)
{
Resume();
} else
{
Pause();
}
}
}
void Resume ()
{
pauseMenuUI.SetActive(false);
Time.timeScale = 1f;
GameIsPaused = false;
}
void Pause ()
{
pauseMenuUI.SetActive(true);
Time.timeScale = 0f;
GameIsPaused = true;
}
public void LoadMenu()
{
Time.timeScale = 1f;
SceneManager.LoadScene("Main Menu");
}
public void QuitGame()
{
Debug.Log("Quitting Game...");
Application.Quit();
}
}
Now, I know what needs to be done but I DON'T KNOW HOW! simply telling the cursor to be visible doesn't work. I need a way to disable the cursor lock script when the main menu loads, and I need to be shown where it goes because fun fact, not everyone here is ace scripting and some are beginners and being tossed a segment of script with no context is as unhelpful as not answering at all.
If you have an answer PLEASE show where in the script it goes.
It's really an easy request. Ive been sitting on a finished game for a week now waiting for help with this problem so I can compile the damn thing and so far all Ive gotten is "you already know what needs to be done". Literally like telling a lost person "you know where you want to go" and not giving them directions.
Answer by cydonia · Mar 24, 2018 at 04:40 AM
Never mind I figured it out, for anyone else who may have the same problem I just backwards engineered a lock cursor script and attached it to an empty game object in the main menu scenes hierarchy.
here's the script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MenuCursor : MonoBehaviour {
// Use this for initialization
void Start () {
Cursor.visible = true;
Cursor.lockState = CursorLockMode.None;
}
// Update is called once per frame
void Update () {
}
}
2 years later you helped a beginner with the same issue. Thanks a bunch for actually posting the solution when you figured it out!
3 years later and this was super helpful. Thank you...you just solved a problem ive been on for 3 weeks.
Follow this Question
Related Questions
Need help with pause menu and cursor lock script conflict 1 Answer
Game doesn't start after death and pause menu 1 Answer
Show cursor via collider 0 Answers
Pause menu script help 0 Answers