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 /
avatar image
0
Question by Burridge · May 03, 2015 at 07:57 PM · bugmenu

Menu won't hide when loading different scene

Okay, so I've been searching for about an hour now, and I can't find a solution at all. I started this project earlier today and it's my first project using Unity. I followed the very first tutorial on the site "Roll a Ball". I have then been using it as a baseline to expand it into something different (eventually). I've been playing around with little bits of code here and there, and adding little bits to get a grip for it all.

However now I am stuck. I have a menu page which allows me to start game, load game (which in itself gives a warning because that feature isn't implemented yet) and a quit game button.

It looks like this; http://i.gyazo.com/524684969a803a4a7c89a9e01a3ea45d.png

The problem I am having is this: http://i.gyazo.com/8d95ac9db707b40e38b2d85c2ecc400a.png

Here is the code below.

Menu.cs

 using UnityEngine;
 using System.Collections;
 using CorruptedSmileStudio.MessageBox;
 
 public class Menu : MonoBehaviour 
 {
     void OnGUI () 
     {
         // Make a background box
         GUI.Box (new Rect (10, 10, 100, 120), "Main Menu");
             
         // Make the first button. If it is pressed, Application.Loadlevel (1) will be executed
         if (GUI.Button (new Rect (20, 40, 80, 20), "Start Game")) 
         {
             Application.LoadLevel (1);
         }
 
         // second button
         if (GUI.Button (new Rect (20, 70, 80, 20), "Load Game")) 
         {
             MessageBox.Show (null, "I'm sorry, but the load game feature is not current avalible in this build.", "Load Game Feature", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
             
         // Make the third button.
         if (GUI.Button (new Rect (20, 100, 80, 20), "Quit")) 
         {
             Application.Quit ();
         }
     }
 }


PlayerController.cs

 using UnityEngine;
 using UnityEngine.UI;
 using System.Collections;
 
 public class PlayerController : MonoBehaviour 
 {
 
     public float speed;
     public Text winText;
 
     private Rigidbody rb;
     private int count;
     private float timer;
 
     void Start()
     {
         rb = GetComponent<Rigidbody> ();
         count = 0;
         timer = 0.0f;
     }
 
     void FixedUpdate()
     {
         if (count < 11) 
         {
             timer += Time.deltaTime;
         }
 
         float moveHorizontal = Input.GetAxis ("Horizontal");
         float moveVertical = Input.GetAxis ("Vertical");
 
         Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
 
         rb.AddForce (movement * speed);
 
         CheckIfWon ();
     }
 
     void OnTriggerEnter(Collider other)
     {
         if (other.gameObject.CompareTag ("Pick Up")) 
         {
             other.gameObject.SetActive (false);
             count = count + 1;
         }
     }
 
     void CheckIfWon ()
     {
         if (count >= 11) 
         {
             Application.LoadLevel(0);
         } 
     }
 
     void OnGUI() 
     {
         GUI.Box(new Rect(5, 0, 100, 20), "Cubes: " + count.ToString("0")); // score
         GUI.Box(new Rect(5, 20, 100, 20), "Time: " + timer.ToString("0")); // timer
     }
 }


Thanks for any, and all helpful responses. :)

Comment
Add comment · Show 1
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 hbalint1 · May 03, 2015 at 08:14 PM 0
Share

you sure that on the new scene you didn't add the menu as a component to something?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Burridge · May 03, 2015 at 08:23 PM

Wow, it took ages for this post to appear on the site. I have fixed it since.

http://i.gyazo.com/56c0f220d4e60e493f028d261ad5d932.png

I had to uncheck the "Dont Destroy function" and it now works as I want it to :)

Comment
Add comment · 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

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

switching scene, first one stops to work properly 1 Answer

Character spawn menu bug 0 Answers

Editor menus are invisible 1 Answer

how to make it die and make it permanent(true)? 1 Answer

Button doesn't work after build 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