The While node is not exactly a While loop but rather a coroutine while. This is done to avoid accidental user error with a result of hanging the editor in an infinite loop.
If you replace the While.cs code with the following code bellow it will come up with the results you want, but I am not really sure I this would be a good change to add for the reasons above. Maybe I can add an option in the node inspector for that.
[Description("Once called, will continuously call 'Do' while the input boolean condition is true. Once condition becomes or is false, 'Done' is called")]
Sorry for another false bug report from me, it turns out that finding a real bug in FlowCanvas is not as easy task 🙂 Can you explain how the coroutine while works? If I understand it, perhaps I can find a way to use it without making the above change to the code.
No worries 🙂
Well, right now the While node works like a coroutine. Once the first flow signal is called on the While node, it starts a coroutine which calls “DO” only once every frame until the “Condition” input becomes false.
If the While node is called more times while the coroutine is still running, it is simply ignored. So only after the While node is done (and thus “Done” output is called), will another While loop be possible to take place for this While node.
So, probably due to how it works now, using While node as part of a For Loop will not really work as expected. I will probably need to add this option to do a real While loop (no coroutine) for such cases.