Optimizing my game

In my game I am having an issue with my performance. But let me back up a little and explain where my issue comes from.

It’s like this: My game has 10 scenes (for now, its a long demo!); Each scene is laid out like this:

Scene
3d room
Up to three cameras and each with their own SSAO and Bloom components
Room Lighting
3d Object that moves (using iTween)
I also have an FPS counter to better illustrate performance. But the thing is that, according to my FPS counter, it shows that my scene runs at 15 (at maximum) FPS and each of my scenes are very simplistic and should at least run at 60+ FPS (at minimum). I went online to research what might the issues be and I found very useful tips like:

making each of my scene’s room be static,
using light-mapping
writing up a script that enables the Bloom and SSAO effect for the active camera and disabling the unused cameras.
But this only caused my FPS to go up by only 2 or 3. And I also clicked on statistic in the Game window and the odd thing is that Unity’s FPS show that my game is running at 60, 70 and even 89 FPS but my in-game FPS says that my game is running at 15, 17 OR 19 FPS.

Of course, I have done this testing in my executable and it is still runs at 15 FPS so I do not know why it is still doing this.

What I want to know is,could it be because of my many scenes scenes? While running one scene, could Unity be rendering all of my scenes in the background at the same time? Or an even broader question: what other improvements have I missed that will help improve my FPS?

Thank you for your time and many more thanks in advance!

Disable the unused cameras, don’t disable their effects.

I did but it still does not improve the FPS

Use the profiler. Otherwise you’re just guessing.

I have a question, is there a way to access the player settings programatically? Mainly, I want to set a boolean value for the Static Batching and Dynamic Batching.

That doesn’t happen.

Okay, thank you. What about accessing the static batching feature found in Player setting? I need to access it programmatically.

Like KelsoMRK suggests, figure out what’s causing the performance issue first. Don’t worry about static batching, post-processing effects, or anything like that yet. You can’t productively optimize until you know what you need to optimize.

Also a good tip which I’ve learned the hard way a few days ago : Get rid of all Debug.Log calls. I’ve spent about an hour staring at the code and wondering why my single scene with 20 sprites was running on 17 fps. Turns out I’ve left 4 Debug.Log calls in the OnGUI code I was working on before.

But maybe it’s just me being an idiot. Q_Q

Just to check, are you sure your in-game FPS script works correctly?

Yes the script runs correctly

Thats really weird because debug.log calls take up basically no processing power… if they are demining the performance of the game that much, there is a problem with your code somewhere… And it needs to be optimised. Try optimising all the code you can throughout your whole project, this can greatly improve performace in some cases :slight_smile:

Not really.

Debug log will happily ruin any computer. They take up a lot of time, due to the unity editor overhead. Especially if you’re flooding the editor with several per frame.

Wow I have never had this problem, I usually run several debug.log calls simultaneously in infinite loop functions and I have never had a performance issue with it :face_with_spiral_eyes:
I guess it would vary greatly depending on the specs of the computer it is running on.

At least I know now for future :slight_smile:

I’m running a 4770k at 4.6ghz and it will still bog down. Depends how many you’re doing per frame but it’s certainly been an ongoing issue with unity.

In my experienced, I always to check performance profiler (CPU usage, GPU usage, Memory usage) on unity3d first and then find function to top overheads.
I think you should to know on where comes from delay or which functions leads to delayed and why…
Srry my native is not english so not good but i wish this will be helpful to you.

– ref –

– ref –

→ Kinds of like this custom profiler always helpful on my projects performance optimizations.