Optimizing Coroutines

Unity Profiler Course

A coroutine allows you to spread tasks across several frames. In Unity, a coroutine is a method that can pause execution and return control to Unity but then continue where it left off on the following frame.

This is the standard example of coroutine which tells the program to stop the processing of loop for 0.5 sec before continuing from the same place.

Here, this is the optimized version of coroutine which bounds the use of new keyword to a single time decreasing the Garbage collection every time the new keyword needed to be used.




Unity Developer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Android Inter-Process Communication (IPC) — it’s biggest limitation?

What Redis? Is it Reddit?

Automate your GitHub workflows with PROBOT

Pods in Kubernetes — The Smallest Deployable Units of Computing

Introduction to Pandas, NumPy and RegEx in Python

Virtual Memory

Beginner Programmer Tips and Tricks


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
Niraj Karki

Niraj Karki

Unity Developer

More from Medium

Day 113: Player Movement Part 1

Slot Rotation Solution:2

Lua Global Variable Code Specification

Creating Character Animations in Timeline and Tackling Some Known Issues