| namespace Unity.VisualScripting |
| { |
| |
| |
| |
| [UnitCategory("Control")] |
| [UnitOrder(0)] |
| [RenamedFrom("Bolt.Branch")] |
| [RenamedFrom("Unity.VisualScripting.Branch")] |
| public sealed class If : Unit, IBranchUnit |
| { |
| |
| |
| |
| [DoNotSerialize] |
| [PortLabelHidden] |
| public ControlInput enter { get; private set; } |
|
|
| |
| |
| |
| [DoNotSerialize] |
| [PortLabelHidden] |
| public ValueInput condition { get; private set; } |
|
|
| |
| |
| |
| [DoNotSerialize] |
| [PortLabel("True")] |
| public ControlOutput ifTrue { get; private set; } |
|
|
| |
| |
| |
| [DoNotSerialize] |
| [PortLabel("False")] |
| public ControlOutput ifFalse { get; private set; } |
|
|
| protected override void Definition() |
| { |
| enter = ControlInput(nameof(enter), Enter); |
| condition = ValueInput<bool>(nameof(condition)); |
| ifTrue = ControlOutput(nameof(ifTrue)); |
| ifFalse = ControlOutput(nameof(ifFalse)); |
|
|
| Requirement(condition, enter); |
| Succession(enter, ifTrue); |
| Succession(enter, ifFalse); |
| } |
|
|
| public ControlOutput Enter(Flow flow) |
| { |
| return flow.GetValue<bool>(condition) ? ifTrue : ifFalse; |
| } |
| } |
| } |
|
|