- Home /
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
Your answer
Follow this Question
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