- Home /
GUI Error: You are pushing more GUIClips than you are popping?
I do not know why I am getting this error.
I have checked over my code for the fifth time now, but I am closing all of my groups using GUILayout.
void OnGUI()
{
GUILayout.BeginArea(new Rect(Screen.width / 2 * 0.02f, Screen.height / 2 * 0.02f, Screen.width, Screen.height));
GUILayout.BeginHorizontal();
if (Network.peerType == NetworkPeerType.Disconnected)
{
if (GUILayout.Button("Start Server", GUILayout.Width(120), GUILayout.Height(25)))
{
Network.InitializeSecurity();
Network.InitializeServer(_maxConnections, _serverPort, true);
}
}
else
{
if (GUILayout.Button("Shutdown Server", GUILayout.Width(120), GUILayout.Height(25)))
{
if (_showLog)
{
_showLog = !_showLog;
}
Network.Disconnect(500);
Debug.Log("Server is shutting down..");
}
if (GUILayout.Button("Show Server Logs", GUILayout.Width(120), GUILayout.Height(25)) && _showLog == false)
{
_showLog = !_showLog;
}
if (_showLog)
{
if (GUILayout.Button("Hide Server Logs", GUILayout.Width(120), GUILayout.Height(25)) && _showLog == true)
{
_showLog = !_showLog;
}
}
}
GUILayout.EndHorizontal();
GUILayout.BeginVertical();
if (_showLog)
{
GUILayout.Box("Server Console", GUILayout.Width(Screen.width / 1.02f), GUILayout.Height(Screen.height / 2));
}
else
{
return;
}
GUILayout.EndVertical();
GUILayout.EndArea();
}
Maybe something I misplaced in my code? I don't see it..
i once had a similar problem. I think the problem was something with the 'if's (OnGUI fires multiple times per frame, but in between layout and draw the variable changed). i then used an intermediate variable which i made sure could only change once per frame. i'm guessing wildly, it could be the peertype disconnted. $$anonymous$$aybe you can check that.
Thanks for the reply, ValooFX.
It turns out the return; was the troublemaker. But I fixed it, if left empty the box disappears too :).
Your answer
Follow this Question
Related Questions
Correct usage of GUILayout.BeginVertical 1 Answer
TextField does not show up 2 Answers
Styling an individual button in SelectionGrid 0 Answers
Invisible BeginScrollView thumb 0 Answers
How to put a GUILayout button BESIDE another one instead of below? 1 Answer