May 4, 2023

UNITY PERFORMANCE: FindObjectOfType => outside of start() or awake() is problematic






 Just a heads up on something I was unaware. As I added many climbable ladders to my city, I started noticing the frames dropping and while using Profiler, I noticed it was due to the Update loop. There was a reference in the Update loop to the FindObjectOfType call, which I thought was done only once during the gameobject initialization.

I put the FindObjectOfType references in the Awake() method instead, and my framerate doubled, from 60 to 120. So, heads up! :-P


BEFORE:


AFTER:




1 comment:

  1. Oi amigo, tudo o que me lembro de ter visto dele pus no tumblr aí :/ Pesquisando no google tb não mostra grandes resultados

    ReplyDelete

Faça-se ouvir. Diga o que acha a respeito deste assunto!