Memorize WaitForSeconds- C# Skill in Unity: 1

Quick tip: store WaitForSeconds to treat your script better.

When using coroutine in script, especially with loop, we usually call it after a keyword “new”, like new WaitForSeconds(). In fact, you can make it easier to process this script without creating a new class every specific time.

Reference of WaitForSeconds()

To make it easier, you can get the reference of WaitForSeconds() to release more memory usage on a script.

Then assign it to a new WaitForSeconds.

Usage in coroutine

When calling a coroutine, you can use the created reference instead of setting a new class to repeat that coroutine.

Imagine that this script would repeat from the very beginning of your game and till the end of it, it would save lots of memory with this way, instead of calling the coroutine every fixed time with the waste of memory.
It should be helpful when developing a big project.

--

--

--

A passionate gamer whose goal is to work in video game development.

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

Recommended from Medium

What Programming Language should I learn?

How to Build Native App With Flutter — Step-by-Step Guide

My Internship Experience at Fintroops

Linear vs. Gamma, but Why??

Unity: Implementing our speed power up

Dual Simplex Method

Combinatorics of alphabet parenthesization

Bitbucket Webhooks Example: Deploy with PHP in a secure way

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
S.J. Jason Liu

S.J. Jason Liu

A passionate gamer whose goal is to work in video game development.

More from Medium

How to use Post Processing in Unity

C# LINQ — “OrderBy”

Did you just hit me! — Hitbox attack system in Unity2D