Viewing entries tagged
coroutine

Wrapping Unity C# Coroutines for Exception Handling, Value Retrieval, and Locking

Wrapping Unity C# Coroutines for Exception Handling, Value Retrieval, and Locking

Coroutines are awesome.  If you aren't familiar with them (particularly in the context of Unity3d) then you should be.  In short, coroutines are methods that can suspend and resume execution.  In the context of Unity what this means is that you can have methods that appear to run concurrently.  Coroutines are **the** way to script a lot of things in Unity, however there are a few problems that you may run into if you use them heavily: exception handling, return values, and locking. Especially if you use nested coroutines!  Here are some ways to extend coroutines to fix some of these issues.