Looking for help on Unity answers is like getting medical advice on Yahoo answers or gaming advice on 4chan /v/.
Will try again with a more concise and to the point question and hope I get a better answer than "you already know what needs to be done"
How to get the Cursor to be visible after returning to main menu.
Ok I'm trying to make a simple pause menu that lets the player return to the main menu. So far it does that however when the Main menu loads the cursor is locked and not visible.
I am using the standard FPSconteroller because I'm a beginner at scripting and simply "script your own!" is not an option.
here's the 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();
}
}
All I need to do is disable the FPS controller script or mouse lock script when I return to main menu.
Any help would be appreciated. The game is done beyond the pause menu, everything else worked but a simple pause menu is tripping me up, I JUST need to be able to return to the main menu with a functioning and visible cursor.
To sum up, how do I disable the mouse hide and lock script upon loading the main menu from a level and where in the code would I put such a command? Seriously if you have an answer show me where to put it, the scrip is useless if I don't know where it goes.
I know what needs to be done but I don't know how to do it.
On a related note if you know of a simple script that allows for a canvas to be toggled on and off with a button click that would also be helpful.
Answer by exzizt · Mar 21, 2018 at 10:09 PM
In the Main Menu scene, have Cursor.visible = true;
somewhere.
That doesn't work
The problem is the cursor lock script. That needs to be turned off.
Also I don't know where in the script to put that. I tried in the menu load section but it didn't work.
Sounds like you already know what it is you need to do! :)
I know what needs to be done I don't know how to do it. I know the cursor lock script needs to be turned off, I don't know how to do it.
It's like being lost, I know I need to go home, but don't know how to get there.