Quantcast
Channel: Answers by "gfoot"
Viewing all articles
Browse latest Browse all 95

Answer by gfoot

$
0
0
Using coroutines you can't get around the need for the "yield return" bit, but you can move the "StartCoroutine" into the called function, so long as that function has a sensible Component to call it on. It won't necessarily feel any better though. Another approach is to use a generic wait method on bob, jim, etc, which is not shorter but is perhaps tidier: bob.say("Hello, I'm Bob"); yield return bob.wait(); jim.walkToPoint(10, 20); yield return jim.wait(); So in these cases 'wait' would return the Coroutine, and would internally call StartCoroutine passing a private IEnumerator method. You could make 'wait' actually be a member of the caller if that helps. There are a lot of different ways to structure it, but I don't think any are ideal.

Viewing all articles
Browse latest Browse all 95

Trending Articles