- Home /
Unity web player slow response to first interaction
Hi everybody,
I'm loading a small prototype to the web browser which just consists of unity UI buttons and menus. It loads quickly and works well until you press the first button. Then it takes a long time to respond (~10 s) before opening the appropriate menu. However after it does this the first time, all other interactions respond normally. This happens in both safari and firefox and does not disappear when I recompile. Any thoughts on what this could be?
It freezes for a long time. On a mac I even get the spinning pinwheel cursor. When running the profiler in the editor I get a spike on button press (Canvas.SendWillRenderCanvases using most of the resources), but it quickly drops back to regular frame rate.
Ok I see what you meant. On clicked the button calls this method in the UI manager:
public void LeftButtonPressed() {
ChangeForgeState (forgeState.cardSelect);
leftButton$$anonymous$$enu.GetComponent<Forge_$$anonymous$$enu_Appear> ().Open$$anonymous$$enu ();
}
the 'ChangeForgeState' method just activates and deactivates some UI elements:
void ChangeForgeState ( forgeState _newState)
{
switch (_newState) {
case forgeState.cardSelect:
buttonLeft.SetActive(false);
buttonRight.SetActive(false);
buttonTop.SetActive(false);
break;
case forgeState.forge:
buttonLeft.SetActive(true);
buttonRight.SetActive(true);
buttonTop.SetActive(true);
break;
}
}
meanwhile the menu appear has a small animation for the menu to appear:
public void Open$$anonymous$$enu () {
gameObject.SetActive (true);
StartCoroutine(transform.$$anonymous$$oveTo (targetLocation.localPosition, animationDuration, Ease.QuadInOut));
StartCoroutine(transform.ScaleTo (Vector3.one * targetScale, animationDuration, Ease.QuadInOut));
}
($$anonymous$$oveTo and ScaleTo are tweening methods from the Automotion plug-in)
The menu that appears contains one panel and 10 buttons, but none have any special code on being enabled.
Answer by ElChileVengador · Aug 18, 2015 at 06:42 AM
Issue has been fixed. Apparently the culprit was the font renderer with the method Font.CacheFontForText. The solution was found in this thread:
http://forum.unity3d.com/threads/massive-font-cachefontfortext-cpu-spike-using-default-gui.227022/
Your answer

Follow this Question
Related Questions
Extremely Slow Game Launching and Build 1 Answer
Unity UI is very slow?!? 1 Answer
Why can't I build Web Player in Unity while I have no problems with building standalone versions? 2 Answers
Unity UI slow?(WaitingForJob and Canvas.RenderOverlays related problem) 1 Answer
Sluggish Controls in FPS Scene. 1 Answer