Home > database >  Unity 2d project runs very slow and uses 90 % of CPU
Unity 2d project runs very slow and uses 90 % of CPU

Time:08-28

I have a 2d project that started running extremely slow. I've tried to backtrack what I did but I can't remember what exactly happened that caused this, as it was running perfectly at one point. Here's a screenshot of the profiler:

enter image description here

What I've tried:

  • Updating my GPU to the latest version
  • Updating Unity to the latest version
  • Restarting the editor multiple times
  • Restarting my PC multiple times
  • Lowered the framerate via custom interaction mode

I'm quite new to Unity, and quite frankly I'm very lost right now. I've been Googling this for hours now. Any help is greatly appreciated.

Screenshot of profile in hierarchy view: enter image description here

CodePudding user response:

There should be smth with your grid or tile map, try to turn off those components. If fps raises, try to recreate tilemap/grid

CodePudding user response:

1119.19ms is a solid second meaning you get less than 1 FPS. For 60 FPS, you should not use more than 16,666ms.

Use the Profiler. (Window -> Analysis -> Profiler) it will tell you what takes up time.

Enable the "Stats" in Game View. For pc, Triangles should be below 6 Million and Batches (drawCalls) should be lower than ~4000 preferably. These numbers are purely for reference on high-end CPU and GPU for a 3D Game, but if you have a BIG difference you should look into that (Like 60k Batches or 20M Triangles would be BAD). GPU Instancing can lower DrawCalls. Making all the non-moving things static in your scene will help as well. Re-Use materials as often as you can. But the most important thing: Profile. You need to know your bottleneck.

CodePudding user response:

You can manually boost performance using simple script

void Start()
{
    // Make the game run as fast as possible
    Application.targetFrameRate = 300;
}
  • Related