• 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
Question by Rxanadu · Apr 19, 2013 at 09:16 PM · booleanguitexttimescaleguilayout

Having trouble making Level Complete text, GUI appear

I'm trying to create some "Level Complete" text which appears when the player completes all of the objectives of the game. It's supposed to function as follows:

  1. The game pauses

  2. The screen darkens a bit

  3. The text appears

  4. Numerous options (e.g. "replay level", "continue", "main menu") appear underneath text

  5. Game "un-pauses" after player chooses one of the options available

To make this all happen, I'm using a GUIText element as the "Level Complete" text and some GUILayout buttons for the options after beating the level.

Right now, the script handling the above functions is referencing a Boolean variable (from another script)which checks if all objectives have been completed. If this variable holds a value of true, then the GUIText and GUILayout buttons should appear on screen. Here's an example of what I'm trying to do with the GUI elements:

 void OnGUI()
     {
         //start GUI elements as disabled, so they don't show
         GUI.enabled = false;
         GUI.color = Color.clear;
 
         //using GUILayout for nicer look
         GUILayout.BeginArea(new Rect(Screen.width / 2 - guiWidth / 2, Screen.height / 2 - guiHeight / 2, guiWidth, guiHeight));
         {
             GUILayout.BeginHorizontal();
             {
                 //Time.timeScale = 0;
                 if (GUILayout.Button("Replay"))
                 {
                     //Time.timeScale = 1;
                     Application.LoadLevel("");
                     gc.goalComplete = false;
                 }
                 if (GUILayout.Button("Continue"))
                 {
                     //Time.timeScale = 1;
                     Application.LoadLevel("");
                     gc.goalComplete = false;
                 }
                 if (GUILayout.Button("Main Menu"))
                 {
                     //Time.timeScale = 1;
                     Application.LoadLevel("MainMenu");
                     gc.goalComplete = false;
                 }
             }
             GUILayout.EndHorizontal();
         }
         GUILayout.EndArea();
 
         //if all goals are complete, then display GUI elements
         if (gc.goalComplete == true) {
             GUI.enabled = true;
             GUI.color = Color.white;
         }
     }

Unfortunately, neither the GUIText nor the GUILayout elements are appearing when the Boolean variable is true. Right now, I wanted to ensure the GUI appears properly; the other elements (i.e. pausing the game after the level ends, fading to darker color) can wait.

Comment

People who like this

0 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 Aezur · Dec 05, 2013 at 02:49 PM 0
Share

I'm having exatly the same problem. It seems to work fine if you put the 'void onGUI' into the same script as the one holding the bool, but as soon as I put it into another script (and update the references), nothing works!!!

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

12 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

Related Questions

Making a pause menu resume 2 Answers

Text position of a game object moved upon a key input and overlaid on the other image. 0 Answers

How can bool work in rewinding timescale? 1 Answer

freeze the scene 1 Answer

Inserting text into GUILayout Box? 3 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