C# delegates and events are extremely powerful and understanding them will make your life as a Unity developer much easier. Luckily, they’re pretty easy to learn and you can start incorporating them in your projects today. In this 2 part post, I cover the basics of delegates and how they work, then lead into how you can use delegates as callbacks for your coroutines. With this technique, you can launch a coroutine that can perform whatever action(s) you choose when it’s done, all in a clean and reusable manner.
Part 1 – Delegate Basics (4 mins)
Part 2 – Delegates as Callbacks for Coroutines (4 mins)
Conclusions
Using delegates can make your project clean and extensible, removing the need for endless if statements, switches, etc.