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 S_Byrnes · Mar 30, 2014 at 04:07 AM · c#leaderboardgui style

Pushing More GUI Clips Than Popping

Hey guys, I'm trying to set up my leaderboard to match my game's GUISkin (it's dreamlo board btw)

But I keep getting these errors when trying to use my GUISkin:

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

 ArgumentException: Getting control 1's position in a group with only 1 controls when doing Repaint
 Aborting
 UnityEngine.GUILayoutGroup.GetNext () (at C:/BuildAgent/work/d3d49558e4d408f4/artifacts/EditorGenerated/GUILayoutUtility.cs:512)
 UnityEngine.GUILayoutUtility.BeginLayoutGroup (UnityEngine.GUIStyle style, UnityEngine.GUILayoutOption[] options, System.Type LayoutType) (at C:/BuildAgent/work/d3d49558e4d408f4/artifacts/EditorGenerated/GUILayoutUtility.cs:207)
 UnityEngine.GUILayout.BeginHorizontal (UnityEngine.GUIContent content, UnityEngine.GUIStyle style, UnityEngine.GUILayoutOption[] options) (at C:/BuildAgent/work/d3d49558e4d408f4/artifacts/EditorGenerated/GUILayout.cs:234)
 UnityEngine.GUILayout.BeginHorizontal (UnityEngine.GUILayoutOption[] options) (at C:/BuildAgent/work/d3d49558e4d408f4/artifacts/EditorGenerated/GUILayout.cs:226)
 LeaderBoardSample.DoMyWindow (Int32 windowID) (at Assets/dreamlo/LeaderBoardSample.cs:94)
 UnityEngine.GUI.CallWindowDelegate (UnityEngine.WindowFunction func, Int32 id, UnityEngine.GUISkin _skin, Int32 forceRect, Single width, Single height, UnityEngine.GUIStyle style) (at C:/BuildAgent/work/d3d49558e4d408f4/artifacts/EditorGenerated/GUI.cs:1395)


 ArgumentException: Getting control 2's position in a group with only 2 controls when doing Repaint
 Aborting
 UnityEngine.GUILayoutGroup.GetNext () (at C:/BuildAgent/work/d3d49558e4d408f4/artifacts/EditorGenerated/GUILayoutUtility.cs:512)
 UnityEngine.GUILayoutUtility.DoGetRect (UnityEngine.GUIContent content, UnityEngine.GUIStyle style, UnityEngine.GUILayoutOption[] options) (at C:/BuildAgent/work/d3d49558e4d408f4/artifacts/EditorGenerated/GUILayoutUtility.cs:275)
 UnityEngine.GUILayoutUtility.GetRect (UnityEngine.GUIContent content, UnityEngine.GUIStyle style, UnityEngine.GUILayoutOption[] options) (at C:/BuildAgent/work/d3d49558e4d408f4/artifacts/EditorGenerated/GUILayoutUtility.cs:258)
 UnityEngine.GUILayout.DoButton (UnityEngine.GUIContent content, UnityEngine.GUIStyle style, UnityEngine.GUILayoutOption[] options) (at C:/BuildAgent/work/d3d49558e4d408f4/artifacts/EditorGenerated/GUILayout.cs:43)
 UnityEngine.GUILayout.Button (System.String text, UnityEngine.GUILayoutOption[] options) (at C:/BuildAgent/work/d3d49558e4d408f4/artifacts/EditorGenerated/GUILayout.cs:37)
 LeaderBoardSample.DoMyWindow (Int32 windowID) (at Assets/dreamlo/LeaderBoardSample.cs:98)
 UnityEngine.GUI.CallWindowDelegate (UnityEngine.WindowFunction func, Int32 id, UnityEngine.GUISkin _skin, Int32 forceRect, Single width, Single height, UnityEngine.GUIStyle style) (at C:/BuildAgent/work/d3d49558e4d408f4/artifacts/EditorGenerated/GUI.cs:1395)


This is the script it's having problems with:

 using UnityEngine;
 using System.Collections.Generic;
 
 public class LeaderBoardSample : MonoBehaviour {
     float startTime = 10.0f;
     float timeLeft = 0.0f;
     
     public GUISkin guiSkin;
     
     Rect windowRect = new Rect (0, 0, 620, 520);
     private bool toggleTxt = false;
     string stringToEdit = "Text Label";
     float hSliderValue = 0.0f;
     float vSliderValue = 0.0f;
     private float hSbarValuet;
     private float vSbarValue;
     private Vector2 scrollPosition = Vector2.zero;
     
     string playerName = "";
     string code = "";
     
     enum gameState {
         waiting,
         running,
         enterscore,
         leaderboard
     };
     
     gameState gs;
     
     
     // Reference to the dreamloLeaderboard prefab in the scene
     
     dreamloLeaderBoard dl;
     dreamloPromoCode pc;
     
     void Start () 
     {
 
         Time.timeScale = 1.0f;
         Screen.sleepTimeout = SleepTimeout.NeverSleep;
         windowRect.x = (Screen.width - windowRect.width)/2;
         windowRect.y = (Screen.height - windowRect.height)/2;
 
         // get the reference here...
         this.dl = dreamloLeaderBoard.GetSceneDreamloLeaderboard();
         
         // get the other reference here
         this.pc = dreamloPromoCode.GetSceneDreamloPromoCode();
         
         this.timeLeft = startTime;
         this.gs = gameState.waiting;
     }
     
     void Update () 
     {
         if (this.gs == gameState.running)
         {
             this.gs = gameState.enterscore;
         }
     }
     
     void  OnGUI (){
         GUI.skin = guiSkin;
         
         windowRect = GUI.Window (0, windowRect, DoMyWindow, "Leaderboard");
     }
     
     
     
     void  DoMyWindow ( int windowID  ){
         
         GUILayoutOption[] width200 = new GUILayoutOption[] {GUILayout.Width(200)};
         
         float width = 400;  // Make this wider to add more columns
         float height = 200;
         
         Rect r = new Rect((Screen.width / 2) - (width / 2), (Screen.height / 2) - (height), width, height);
         GUILayout.BeginArea(r, new GUIStyle("box"));
         
         GUILayout.BeginVertical();
         if (this.gs == gameState.waiting || this.gs == gameState.running)
         {
             this.gs = gameState.running;
             
             GUILayout.Label("Total Score: " + GameLogicScript.score);
         }
         
         
         
         if (this.gs == gameState.enterscore)
         {
             GUILayout.Label("Total Score: " + GameLogicScript.score);
             GUILayout.BeginHorizontal();
             GUILayout.Label("Your Name: ");
             this.playerName = GUILayout.TextField(this.playerName, width200);
             
             if (GUILayout.Button("Save Score"))
             {
                 // add the score...
                 if (dl.publicCode == "") Debug.LogError("You forgot to set the publicCode variable");
                 if (dl.privateCode == "") Debug.LogError("You forgot to set the privateCode variable");
                 
                 dl.AddScore(this.playerName, GameLogicScript.score);
                 
                 this.gs = gameState.leaderboard;
             }
             GUILayout.EndHorizontal();
         }
         
         if (this.gs == gameState.leaderboard)
         {
             GUILayout.Label("High Scores:");
             List<dreamloLeaderBoard.Score> scoreList = dl.ToListHighToLow();
             
             if (scoreList == null) 
             {
                 GUILayout.Label("(loading...)");
             } 
             else 
             {
                 int maxToDisplay = 20;
                 int count = 0;
                 foreach (dreamloLeaderBoard.Score currentScore in scoreList)
                 {
                     count++;
                     GUILayout.BeginHorizontal();
                     GUILayout.Label(currentScore.playerName, width200);
                     GUILayout.Label(currentScore.score.ToString(), width200);
                     GUILayout.EndHorizontal();
                     
                     if (count >= maxToDisplay) break;
                 }
             }
         }
         GUILayout.EndVertical();
         GUILayout.EndArea();
     }
     
     
 }

Any help would be very much appreciated! Thanks!

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

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

Distribute terrain in zones 3 Answers

C# Unity 3D Lock Rotation but allow Rotation of Parent Object 1 Answer

Multiple Cars not working 1 Answer

C# Script Template - how to make custom changes? 1 Answer

C# Unity 3D: LookAt.cs Help please 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