Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
This question was closed Mar 24, 2018 at 04:41 AM by cydonia for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by cydonia · Mar 24, 2018 at 04:18 AM · scripting problemcursordisablepause menumainmenu

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.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

  • Sort: 
avatar image
2
Best Answer

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 () {
         
     }
 }
Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image JosephFlack · Jun 19, 2020 at 01:08 AM 0
Share

2 years later you helped a beginner with the same issue. Thanks a bunch for actually posting the solution when you figured it out!

avatar image atagbuzc · Apr 08, 2021 at 04:52 PM 0
Share

3 years later and this was super helpful. Thank you...you just solved a problem ive been on for 3 weeks.

Follow this Question

Answers Answers and Comments

194 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

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

C# Disabling Camera moving while in Pause Menu 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges