Nerd For Tech
Published in

Nerd For Tech

Optimizing Coroutines in Unity

Coroutines are extremely useful for any time specific function, however when one uses the yield return new function, that uses a lot of garbage allocation resources as every time the new keyword is used, Unity has to build that new thing on the spot.

This is where caching WaitForSeconds comes in. Think of Caching the WaitForSeconds as a Hot-N-Ready WaitForSeconds routine just waiting for anyone to pick it up and use it!

Since the WaitForSeconds is already built and available, when the coroutine is run, Unity doesn’t have to go through any more extra steps and potentially slow your game down!

The key takeaway here is an important concept in optimizing code is caching your data! Hope it helps!

NFT is an Educational Media House. Our mission is to bring the invaluable knowledge and experiences of experts from all over the world to the novice. To know more about us, visit

Recommended from Medium

Cloud agnostic object storage for everybody with Cloud 66 and Minio.

Yieldly Adds AlgoSigner Support

Autel MaxiLink ML529 OBD2 Scanner Car Auto Diagnostic Tool OBD 2 EOBD Code Reader Full OBDII…

Terraform in Azure Devops without additional tasks

Microservices E-commerce Boutique Tutorial — part 3

Series Three: Git Essential Training: The Basics.

Say hello! 👋 to Flutter Desktop 🤗 (Windows + macOS + Linux)

Huawei mobile service

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Esteban Ibarra

Esteban Ibarra

cartoonist, game artist, and wanabe gamedev.

More from Medium

Unity Development — The Resources Folder

My journey becoming a Unity game developer: Sleeping Guard Interaction-Player NavMesh movement…

Structuring Your Unity Code For Production: Important Best Practices

Eyesight in Unity