• 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 Dknighter · Jan 26, 2014 at 04:28 PM · guierrormenupushingpopping

GUI Error: You are pushing more GUIClips than you are popping. Make sure they are balanced)

I have an error in my GUI script for my main menu. I get: GUI Error: You are pushing more GUIClips than you are popping. Make sure they are balanced)

I know what this error means as I've sat here googling it over and over again but yet all the solutions are the same. I must have as many "Ends" as there are "Begins" but that doesn't seem to be the problem as it is fine.

I also get the error: You can only call GUI functions from inside OnGUI. However this does not affect anything on the script.

Here's my script (It's very long I know)

DO NOT USE THIS SCRIPT IN YOUR PROJECTS, IT IS OWNED BY ME AND ONLY ME

 using UnityEngine;
 using System.Collections;
 
 public class MainMenu : MonoBehaviour
 {
     private Menus currentMenu = Menus.Main;
     private bool canSwitch = false;
     public Vector2 scrollPosition;
 
     public GUISkin MySkin;
 
     private int buildingindex;
     private string buildingname;
     
     private float RenderSliderValue = 0.0F;
     private float ShadowSliderValue = 0.0F;
     private float TextureSliderValue = 0.0F;
     private float MasterVSliderValue = 0.0F;
 
     private bool VSync = false;
 
     //Controls
     private string ForwardText = "W";
     private string BackText = "S";
     private string LeftText = "A";
     private string RightText = "D";
     private string JumpText = "SPACE";
 
     enum Menus
     {
         Main,
         Options,
         Sound,
         MyGraphics,
         Credits,
         MyGUI,
         Controls,
     }
 
     void OnGUI()
     {    
         GUI.skin = MySkin;
         switch(currentMenu)
         {
             case Menus.Main:
                 Main();
             break;
 
             case Menus.Options:
                 Main();
                 Options();
             break;
                             
             case Menus.Sound:
                 Main();
                 Sound();
             break;
 
             case Menus.MyGraphics:
                 Main();
                 MyGraphics();
             break;
 
             case Menus.Credits:
                 Main();
                 Credits();
             break;
 
             case Menus.Controls:
                 Main();
                 Controls();
             break;
             }
     }
     
     //These are to control the main buttons on the menu
     
     void Main()
     {
         GUILayout.BeginArea(new Rect(Screen.width / 4, 0, 200, Screen.height));
         GUILayout.FlexibleSpace();
         GUILayout.BeginVertical();
         GUILayout.FlexibleSpace();
 
         GUILayout.Box("Main Menu");
         
         scrollPosition = GUILayout.BeginScrollView(scrollPosition, GUILayout.Width(200), GUILayout.Height(200));
         if(GUILayout.Button("New Game")){
             //Load New Game
         }
         if(GUILayout.Button("Load Game")){
             //Load Saved Scene Data
         }
         if(GUILayout.Button("Options")){
             currentMenu = Menus.Options;
         }
         if(GUILayout.Button("Credits")){
             currentMenu = Menus.Credits;
         }
         if(GUILayout.Button("Quit Game")){
             Application.Quit();
         }
         GUILayout.EndScrollView();
         GUILayout.FlexibleSpace();
         GUILayout.EndVertical();
         GUILayout.FlexibleSpace();
         GUILayout.EndArea();
     }
 
     void Options()
     {
             GUILayout.BeginArea(new Rect(Screen.width / 2, 0, 200, Screen.height));
             GUILayout.FlexibleSpace();
             GUILayout.BeginVertical();
             GUILayout.FlexibleSpace();
             
             GUILayout.Box("Options");
             
             scrollPosition = GUILayout.BeginScrollView(scrollPosition, GUILayout.Width(200), GUILayout.Height(200));
             if(GUILayout.Button("Graphics")){
             currentMenu = Menus.MyGraphics;
             }
             if(GUILayout.Button("Sound")){
             currentMenu = Menus.Sound;
             }
             if(GUILayout.Button("Controls")){
                 currentMenu = Menus.Controls;
             }
             GUILayout.EndScrollView();
             GUILayout.FlexibleSpace();
             GUILayout.EndVertical();
             GUILayout.FlexibleSpace();
             GUILayout.EndArea();
     }
 
     void Credits()
     {
             GUILayout.BeginArea(new Rect(Screen.width / 2, 0, 200, Screen.height));
             GUILayout.FlexibleSpace();
             GUILayout.BeginVertical();
             GUILayout.FlexibleSpace();
             
             GUILayout.Box("Credits");
             
             scrollPosition = GUILayout.BeginScrollView(scrollPosition, GUILayout.Width(200), GUILayout.Height(200));
             GUILayout.Label("Lead Developer: Daniel Knight");
             GUILayout.Label("Lead Programmer: Daniel Knight");
             GUILayout.Label("Lead Modeller: Teo Tuder");
             GUILayout.Label("Lead Developer: Daniel Knight");
             GUILayout.FlexibleSpace();
             GUILayout.Label("SPECIAL THANKS");
             GUILayout.Label("F33L!");
             GUILayout.Label("ThePenisBoy");
             GUILayout.Label("Nick");
             GUILayout.Label("Killerbill");
             GUILayout.Label("HailTheFail");
             GUILayout.Label("lateroflife");
             GUILayout.Label("Anttony Koibu");
             GUILayout.Label("Cornelius Kilegran");
             GUILayout.Label("Jack Mitchell");
             GUILayout.Label("Jack Skinner");
             GUILayout.Label("Ashwin Bali");
             GUILayout.Label("Ian Hell");
             GUILayout.Label("Peyton");
             GUILayout.Label("Sven Linnemann");
             GUILayout.Label("Teo Tudor");
             GUILayout.Label("Simon|Gagup|Skullbeat");
             GUILayout.Label("Tim cleall");
             GUILayout.Label("CalmCaterpillar");
 
             GUILayout.EndScrollView();
             GUILayout.FlexibleSpace();
             GUILayout.EndVertical();
             GUILayout.FlexibleSpace();
             GUILayout.EndArea();
     }
     void MyGraphics()
     {
             GUILayout.BeginArea(new Rect(Screen.width / 2, 0, 200, Screen.height));
             GUILayout.FlexibleSpace();
             GUILayout.BeginVertical();
             GUILayout.FlexibleSpace();
             
             GUILayout.Box("Graphics");
             
             scrollPosition = GUILayout.BeginScrollView(scrollPosition, GUILayout.Width(200), GUILayout.Height(200));
 
             GUILayout.Label("Render Distance");
             RenderSliderValue = GUILayout.HorizontalSlider(RenderSliderValue,0.0f,10.0f);
 
             GUILayout.Label("Shadow Distance");
             ShadowSliderValue = GUILayout.HorizontalSlider(ShadowSliderValue,0.0f,10.0f);
 
             if(GUILayout.Button("V-Sync On/Off"))
             {
                 if(VSync)
                 {
                     VSync = true;
                     QualitySettings.vSyncCount = 1;
                 }
                 else
                 {
                     VSync = true;
                     QualitySettings.vSyncCount = 0;
             }
 
             GUILayout.Label("Texture Quality");
             TextureSliderValue = GUILayout.HorizontalSlider(TextureSliderValue,0.0f,10.0f);
 
             GUILayout.EndScrollView();
             GUILayout.FlexibleSpace();
             GUILayout.EndVertical();
             GUILayout.FlexibleSpace();
             GUILayout.EndArea();
         }
     }
 
     void Controls()
     {
             GUILayout.BeginArea(new Rect(Screen.width / 2, 0, 200, Screen.height));
             GUILayout.FlexibleSpace();
             GUILayout.BeginVertical();
             GUILayout.FlexibleSpace();
             
             GUILayout.Box("Controls");
             
             scrollPosition = GUILayout.BeginScrollView(scrollPosition, GUILayout.Width(200), GUILayout.Height(200));
             
             GUILayout.Label("Forward");
             ForwardText = GUILayout.TextField(ForwardText.ToUpper(),10);
 
             GUILayout.Label("Back");
             BackText = GUILayout.TextField(BackText.ToUpper(),10);
 
             GUILayout.Label("Left");
             LeftText = GUILayout.TextField(LeftText.ToUpper(),10);
 
             GUILayout.Label("Right");
             RightText = GUILayout.TextField(RightText.ToUpper(),10);
 
             GUILayout.Label("Jump");
             JumpText = GUILayout.TextField(JumpText.ToUpper(),10);
             
             GUILayout.EndScrollView();
             GUILayout.FlexibleSpace();
             GUILayout.EndVertical();
             GUILayout.FlexibleSpace();
             GUILayout.EndArea();
     }
 
     void Sound()
     {
             GUILayout.BeginArea(new Rect(Screen.width / 2, 0, 200, Screen.height));
             GUILayout.FlexibleSpace();
             GUILayout.BeginVertical();
             GUILayout.FlexibleSpace();
             
             GUILayout.Box("Sound");
             
             scrollPosition = GUILayout.BeginScrollView(scrollPosition, GUILayout.Width(200), GUILayout.Height(200));
             
             if(GUILayout.Button("Sound On/Off"))
             {
                 if(AudioListener.volume != 0)
                 {
                     AudioListener.volume = 100;
                 }
                 else
                 {
                     AudioListener.volume = 0;
             }
 
             GUILayout.Label("Master Volume");
             MasterVSliderValue = GUILayout.HorizontalSlider(MasterVSliderValue,0.0f,10.0f);
 
             
             GUILayout.EndScrollView();
             GUILayout.FlexibleSpace();
             GUILayout.EndVertical();
             GUILayout.FlexibleSpace();
             GUILayout.EndArea();
         }
     }
 }

I know the buttons everything inside the script doesn't do anything as I have only just started with this script

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 kurotatsu · Jul 21, 2014 at 04:16 PM 1
Share

DO NOT USE THIS SCRIPT IN YOUR PROJECTS, IT IS OWNED BY $$anonymous$$E AND ONLY $$anonymous$$E

O$$anonymous$$G, your script is just so brilliant and unique, you should go out and patent it right away!!!

Comments like this, are why no one has offered to assist you.

Your Awesome Brilliant Coding up above, has been done 100 different times, a 100 different ways.

Learn some humility, and doors will open for ya.

All the best, kuro.

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

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

20 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

Related Questions

What exactly this error is trying to inform me about? 1 Answer

Annoying warning with GUI, quick fix? 2 Answers

HighScore analytics 0 Answers

Expecting variable error with a button 1 Answer

GUI Texture error. 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