Optimizing Frame Rate - Saving Screenshot

Optimizing Frame Rate - Saving Screenshot

Today I had an interesting issue while serializing data.

This issue came about while working on SuperStickGame saving functionality. I couldn't find out why when the hero crossed a trigger collider which then execute a call to serialize my level and save it out to a file caused incredible spikes in FPS during the game, making it look very very bad. So what I decided to do is change the way I was calling Application.CaptureScreenshot and instead of trying to fight with IO and heavy writes, I used a very helpful property called Time.captureFramerate which made the frames per second during the file saved be static and then when I finished generating a screenshot it was set back to 0 which resets back.

Here's a sample code I leave you guys in case you are interested in knowing how I coded it the solution:

Code Snippet

 

Thank you for your time and don't forget to subscribe to my newsletter, also be sure to find me at @dilmerv and stop by and say hi as I love to chat with everyone.

Pingbacks are closed.

Trackbacks
Comments