- Home /
GUI framerate drop in Chrome
Hello there. I'm having some problems with the GUI as the title states. In some cases in Google Chrome the GUI framerate drops severely. It takes approximately 0.5 - 1 sec for the GUI button to switch its onHover style. This bug is completely random and I havent found a proper way to reproduce it every time. All I can say is that it happens only in Chrome on an iMac after I've started the game. If I click play and then from the 1st level go back (exit game) to mainMenu scene the framerate usually fixes, but not always.
Let me give you a little input on how I handle GUI.
I have a GUIBase class which has a Show() method. I have custom classes that inherit from GUIBase class and have their Show() methods overridden, respectively. Inside each custom class' Show() I have some GUI code.
I have a main object which has its GUI elements, a few buttons to be exact. Those buttons change state of a property called state which is then passed to a switch/case which determines which gui object to create and call its .Show() method.
I've tested inside editor, safari on iMac and IE, FF, Chrome and editor on windows. On windows it works flawlessly. Same goes for editor and Safari on a mac. I'm experiencing problems only with Chrome.
Any ideas?
Here is a fraction of the code.
GameManager:
switch (state)
{
case "Login":
LoginForm loginForm = new LoginForm();
loginForm.Show();
break;
// REGISTER
case "Register":
RegisterForm registerForm = new RegisterForm();
registerForm.Show();
break;
// PROFILE
case "Profile":
ProfileForm profileForm = new ProfileForm();
profileForm.Show();
break;
}
And a fraction of the code from one of the classes. They are basically the same, they only carry different layouts of the GUI.
LoginForm:
public override void Show()
{
Rect loginRegisterRect = new Rect(0, 0, Screen.width, Screen.height);
if (loginRegisterRect.Contains(Event.current.mousePosition))
{
GameManager.IsGUIButtonOver = true;
}
else
{
GameManager.IsGUIButtonOver = false;
}
GUILayout.BeginArea(loginRegisterRect, GameManager.CustomSkin.GetStyle("RegisterLoginBackground"));
//LOGIN
GUILayout.BeginVertical();
GUILayout.Label("Login", "LabelLoginRegister");
GUILayout.Label("Enter your details", "LabelExplanation");
// labeli i input field
GUILayout.BeginHorizontal();
GUILayout.Label("E-mail"); GameManager.logOnModel.UserName = GUILayout.TextField(GameManager.logOnModel.UserName, 50);
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
GUILayout.Label("Password"); GameManager.logOnModel.Password = GUILayout.PasswordField(GameManager.logOnModel.Password, "*"[0], 50);
GUILayout.EndHorizontal();
GameManager.logOnModel.RememberMe = GUILayout.Toggle(GameManager.logOnModel.RememberMe, "Remember me");
GUILayout.BeginHorizontal();
if (GUILayout.Button("", "ButtonCancel"))
{
GameManager.state = "Hide";
}
if (GUILayout.Button("", "ButtonOk"))
{
Debug.Log("Login...");
if(GameManager.logOnModel.IsValid)
{
GameManager.StartCoroutine(GameManager.LogIn());
GameManager.logOnModel.Password = string.Empty; // Clear password from the Login Form
GameManager.state = "Hide";
}
else
{
GameManager.showErrorLabel = true;
}
}
GUILayout.EndHorizontal();
if(GameManager.showErrorLabel)
GUILayout.Label("Error");
GUILayout.EndVertical();
GUILayout.EndArea();
}
Maybe I'm doing something wrong. Or maybe its just the chrome unity plugin thats messed up. I can't really tell. I was hoping someone might have a solution.
It appears its a Chrome problem and is nothing code related. Once the framerate drops one can easily open a new tab and then just return to the tab the game was initially loaded and everything is fine.
Strange.
Your answer

Follow this Question
Related Questions
GUI buttons aren't clickable in chrome. 0 Answers
GUI.Lable slowdown problem 0 Answers
Is Using Unity's Built In GUI Okay?(IOS) 1 Answer
Frame rate stutters regularly in Chrome + Flash 0 Answers
Integrating CefSharp into Unity 0 Answers