- Home /
Website responsiveness and Unity hogging the CPU
My web based Unity game is interacting with the website and encouraging the user to go back and forth between it and the webpage the game is embedded in.
When the game runs the webpage becomes generally sluggish, scrolling becomes jumpy, etc. That is fine as long as the user is engaged with the game but interacting with the page is a pain.
I figured I can just stop/pause the game when it loses focus (OnApplicationFocus), but no matter what I try at that time, the webpage stays unresponsive.
I tried setting Time.timeScale to 0, Time.fixedDeltaTime to 0.2 or higher, Application.targetFrameRate to 2, disabled all the Cloth objects, etc.
Nothing will stop Unity from hogging all the resources. Is there any way I can limit how much CPU Unity will use? I am fine with completely stopping the game, but I would like to keep the last rendered frame visible.
Thanks for any ideas!
Answer by Justin Warner · May 15, 2012 at 03:28 PM
Hey Matt,
http://forum.unity3d.com/threads/32016-Unity-webplayer-eating-mah-Memory
That looks similiar.
Solution: Application.targetFrameRate
Didn't know this existed, so thanks =).
Thanks for the link, but I have tried targetFrameRate with different settings with no meaningful success.
I get the best result so far by disabling all Renderers in the scene, but that leaves me with an empty background.
I might try to render to a Texture on pause and then disable all the Renderers and show the last frame in a GUI.Box while it's paused.
There has to be a way to add a sleep or something to make Unity take a break and give up CPU resources?!
Your answer
![](https://koobas.hobune.stream/wayback/20220613071507im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Flash vs Webplayer - Performance Investigation 1 Answer
MMO games in the Web Player: lots of players and game performance. 1 Answer
Severe performance problem with 2 instances of web player 3 Answers
Stuttering web player 1 Answer
Performance Differences in Standalone player versus Web Browser? 2 Answers