Maze / Library /PackageCache /com.unity.visualscripting@1.8.0 /Runtime /VisualScripting.Flow /Framework /Logic /ExclusiveOr.cs
| namespace Unity.VisualScripting | |
| { | |
| /// <summary> | |
| /// Returns true if one input is true and the other is false. | |
| /// </summary> | |
| [] | |
| [] | |
| public sealed class ExclusiveOr : Unit | |
| { | |
| /// <summary> | |
| /// The first boolean. | |
| /// </summary> | |
| [] | |
| public ValueInput a { get; private set; } | |
| /// <summary> | |
| /// The second boolean. | |
| /// </summary> | |
| [] | |
| public ValueInput b { get; private set; } | |
| /// <summary> | |
| /// True if either A or B is true but not the other; false otherwise. | |
| /// </summary> | |
| [] | |
| [] | |
| public ValueOutput result { get; private set; } | |
| protected override void Definition() | |
| { | |
| a = ValueInput<bool>(nameof(a)); | |
| b = ValueInput<bool>(nameof(b)); | |
| result = ValueOutput(nameof(result), Operation).Predictable(); | |
| Requirement(a, result); | |
| Requirement(b, result); | |
| } | |
| public bool Operation(Flow flow) | |
| { | |
| return flow.GetValue<bool>(a) ^ flow.GetValue<bool>(b); | |
| } | |
| } | |
| } | |