0
Completed

CoroutineUnit for version 1.4

cooloon 2 years ago updated by Lazlo Bonin (Lead Developer) 1 year ago 4

When we have coroutine method (that yield returns objects as an IEnumerator), it's happy if we could execute the coroutine and then continue the flow after that coroutine, isn't it?

Check out this graph:

This flow graph execute the TestCoroutine method first, it takes some time, and after the TestCoroutine yields break, Debug.Log() will be called.

After the version 1.4, it's easy to implement. The implementation of the CoroutineUnit is like this:

CoroutineUnit.cs

This Unit is so convenient that I wonder if you include this unit officially.


Temporary the CoroutineUnit is a subclass of WaitUnit, there should be a proper place(clock icon for coroutine looks curious), thanks.

Bolt Version:
Unity Version:
Platform(s):
Scripting Backend:
.NET Version (API Compatibility Level):
Planned

Interesting! Basically, it is a wait unit, because it's a "Wait for coroutine", but I guess I could call it "Nested Coroutine" or indeed just "Coroutine" too. I'll look into making this an official unit.

Thanks for your quick replay! I agree with you, it's a kind of wait unit. The reason why I feel the clock icon curious is, I think, I imagine the class hierarchy like this:

- RunCoroutineUnit (current WaitUnit)
  - RunEnumeratorUnit (my CoroutineUnit above)
  - RunYieldInstructionUnit (like WaitForAsyncOperationUnit found <a href="https://support.ludiq.io/communities/5/topics/643-wait-for-load-scene-async-unit">here</a>, but takes YieldInstruction as an input)
  - RunCustomYieldInstructionUnit (CustomYieldInstruction as an input)
  - WaitUnit
    - WaitForXxxUnit
    - WaitForYyyUnit
    - ...

I'd like to say "Run" can be the name because the main purpose of those units are not only waiting but executing something, and coroutine is "running" after StartCoroutine() is called according to the Unity manual.

By the way, the source code of Bolt is soooo beautiful than ever seen! I'm glad to see that, thanks!

Oops, because CustomYieldInstrution inherits from IEnumerator, RunCustomYieldInstructionUnit above doesn't make sense.

+1
Completed

Cleaning up old issues! This was completed in v.2.0.0a4's coroutine overhaul.