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.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
usingSystem.Collections;
usingParadoxNotion.Design;
namespaceFlowCanvas.Nodes{
[Name("While True")]
[Description("Once called, will continuously call 'Do' while the input boolean condition is true. Once condition becomes or is false, 'Done' is called")]
[ContextDefinedInputs(typeof(bool))]
publicclassWhile:FlowControlNode{
protectedoverridevoidRegisterPorts(){
varc=AddValueInput<bool>("Condition");
varfCurrent=AddFlowOutput("Do");
varfFinish=AddFlowOutput("Done");
AddFlowInput("In",(f)=>{
while(c.value){
fCurrent.Call(f);
}
fFinish.Call(f);
});
}
}
}
Let me know what you think.
Cheers.
Join us on Discord: https://discord.gg/97q2Rjh
Login
Register
By registering on this website you agree to our Privacy Policy.