Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by Urbanoutdoorsman · May 30, 2015 at 05:06 PM · c#androiduiunity5

Why does my pause & quit menus appear when I load next level?

When I start my game the menus work as they are supposed to. They are not visible because I have quitMenu.enabled = false; and pauseMenu.enabled = false; at void Start () in code.

It's when I start the next level that my pause menu and exit menu appear at the start of the level even though they are set to false in code. I have looked over this repeatedly and couldn't find the reason. I figure now it's time for a fresh pair of eyes to take a look.

All the functionality works with the exception of the menus appearing at the start of the next level loaded. Also when I go back to the Main Menu the menus aren't visible as they should be because they are set to false in code. I am using the same assets in both scenes with exception of the pause menu, which isn't in the starting scene, but the next scene loaded. I don't get why the code works in the starting scene but not the next scene loaded. Any sort of help would be appreciated.

Here is the code as it stands:

using UnityEngine;

using UnityEngine.UI;

using System.Collections;

 public class menuScript : MonoBehaviour 
 {
     public Canvas quitMenu;
     public Canvas pauseMenu;
     public Button startText;
     public Button exitText;
 
     // Use this for initialization
     void Start () 
     {
         quitMenu = quitMenu.GetComponent<Canvas> ();
         pauseMenu = pauseMenu.GetComponent<Canvas> ();
         startText = startText.GetComponent<Button> ();
         exitText = exitText.GetComponent<Button> ();
         quitMenu.enabled = false;
         pauseMenu.enabled = false;
     }
     
 
     public void ExitPress() 
     {
         quitMenu.enabled = true;
         pauseMenu.enabled = false;
         startText.enabled = false;
         exitText.enabled = false;
     }
 
     public void NoPress()
     {
         quitMenu.enabled = false;
         pauseMenu.enabled = false;
         startText.enabled = true;
         exitText.enabled = true;
         Time.timeScale = 1;//unpauses game
         AudioListener.volume = 0.5f;//unmutes sound
     }
 
     public void StartLevel()
     {
         quitMenu.enabled = false;
         pauseMenu.enabled = false;
         Application.LoadLevel (1);
         Time.timeScale = 1;//unpauses game
         AudioListener.volume = 0.5f;//unmutes sound
     }
 
     public void MainMenu()
     {
         Application.LoadLevel (0);
         Time.timeScale = 1;//unpauses game
         AudioListener.volume = 0.5f;//unmutes sound
     }
 
     public void PauseGame()
     {
         pauseMenu.enabled = true; 
         //gameObject.pauseMenu.enabled = true;
         Time.timeScale = 0;//pauses game
         AudioListener.volume = 0;//mutes sound
     }
 
     public void ResumeGame()
     {
         pauseMenu.enabled = false; 
         Time.timeScale = 1;//unpauses game
         AudioListener.volume = 0.5f;//unmutes sound
     }
 
     public void ExitGame()
     {
         Application.Quit ();
     }
 
 }





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

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

2 People are following this question.

avatar image avatar image

Related Questions

Distribute terrain in zones 3 Answers

UI Button when build to android function does not work 0 Answers

Moving object to position of finger at screen 1 Answer

UI works in editor, but not on mobile device 1 Answer

Please help! After build on Android UI buttons can't enable/disable script but works when using Unity remote. 0 Answers


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