Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 HolBol · Apr 22, 2010 at 09:12 PM · guierrorexceptionjavascript-specific

Quit Menu errors

I have a quit menu script, it works fine, but brings an error up in the unity editor.

private var quitMenu;

 function Update () {

 if (Input.GetKeyDown (KeyCode.Escape)) { 
     if (quitMenu == true) { 

     quitMenu = false; 

     }
     else { 
     quitMenu=true; 

     }
     Time.timeScale = 0; 
    }

}

function OnGUI () { if (quitMenu == true) {

 GUI.BeginGroup (Rect (Screen.width / 2 - 50, Screen.height / 2 - 50, 200, 200));


 GUI.Box (Rect (0,0,100,170), "Game Paused");
 if (GUI.Button (Rect (10,30,80,30), "Resume")) {
 quitMenu = false;
 Time.timeScale = 1;
 }
 if (GUI.Button (Rect (10,80,80,30), "Restart")) {
 quitMenu = false;
 Time.timeScale = 1;
 Application.LoadLevel(0);
 }
 if (GUI.Button (Rect (10,130,80,30), "Quit")) {
      Application.Quit();
 }

}

 GUI.EndGroup ();

}

The error I got was

InvalidOperationException: Operation is not valid due to the current state of the object System.Collections.Stack.Peek () UnityEngine.GUIClip.Pop () UnityEngine.GUI.EndGroup () Quit Menu.OnGUI () (at Assets\Scripts\Quit Menu.js:43) UnityEditor.EditorGUIUtility:RenderGameViewCameras(Rect, Rect, Boolean, Boolean) UnityEditor.EditorGUIUtility:RenderGameViewCameras(Rect, Rect, Boolean, Boolean) UnityEditor.GameView:OnGUI() System.Reflection.MonoMethod:InternalInvoke(Object, Object[]) System.Reflection.MonoMethod:InternalInvoke(Object, Object[]) System.Reflection.MonoMethod:Invoke(Object, BindingFlags, Binder, Object[], CultureInfo) System.Reflection.MethodBase:Invoke(Object, Object[]) UnityEditor.HostView:Invoke(String) UnityEditor.DockArea:OnGUI()

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

2 Replies

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by Eric5h5 · Apr 22, 2010 at 09:15 PM

Put the GUI.EndGroup() line in with the rest of the code. Otherwise you have a mismatched group (end without begin).

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
avatar image
1

Answer by AVividLight · Apr 22, 2010 at 09:28 PM

I have not looked at you script, nor do I know what you want to do, but if it is just to quit you can use my script.

And be sure to click the Quit button in the Inspector!

-Note: I have not edited my script, so it may want you to add some pictures/text.

~Gibson of GBSoftware~

var levelToLoad : String; var normalTexture : Texture2D; var rollOverTexture : Texture2D; var beep : AudioClip; var QuitButton : boolean = false;

function OnMouseEnter(){ guiTexture.texture = rollOverTexture; } function OnMouseExit(){ guiTexture.texture = normalTexture; }

function OnMouseUp(){ audio.PlayOneShot(beep); yield new WaitForSeconds(0.35);

 if(QuitButton){
     Application.Quit();
     Debug.Log("This part works!");
 }
 else{
     Application.LoadLevel(levelToLoad); 
 }

}

@script RequireComponent(AudioSource)

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

No one has followed this question yet.

Related Questions

Loading a scene in game with a GUI 1 Answer

FindWithTag returns NullReferenceException 0 Answers

Inspector removing MeshRenderer generates error 2 Answers

Instantiating object from inventory 0 Answers

Can't draw a box using Basic GUI 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