Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Optimization in Unity GameObject method calls

Releasing game to Prod

I am finished with all components of my game and now I am wondering if it is okay to use FindObjectofType too much? will there be a bad result of using this method?

I tried using FindObjectOftype method in everywhere whenever I need don’t know if it will affect the performance of game or not

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

It is usually ok to use that method. But do not use these methods in Update(). consider using it in Start or Awake method.. According to Unity’s ‘General Optimizations’ you should avoid using ‘Object.FindObjectOfType’ method in production. Since this method requesting UnityEngine to iterate over all GameObjects and Components in memory. Which will cause undesirable drain on performance.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading