namespace Unity.VisualScripting { /// /// Returns true if one input is true and the other is false. /// [UnitCategory("Logic")] [UnitOrder(2)] public sealed class ExclusiveOr : Unit { /// /// The first boolean. /// [DoNotSerialize] public ValueInput a { get; private set; } /// /// The second boolean. /// [DoNotSerialize] public ValueInput b { get; private set; } /// /// True if either A or B is true but not the other; false otherwise. /// [DoNotSerialize] [PortLabel("A \u2295 B")] public ValueOutput result { get; private set; } protected override void Definition() { a = ValueInput(nameof(a)); b = ValueInput(nameof(b)); result = ValueOutput(nameof(result), Operation).Predictable(); Requirement(a, result); Requirement(b, result); } public bool Operation(Flow flow) { return flow.GetValue(a) ^ flow.GetValue(b); } } }