namespace Unity.VisualScripting { /// /// Returns true if both inputs are true. /// [UnitCategory("Logic")] [UnitOrder(0)] public sealed class And : Unit { /// /// The first boolean. /// [DoNotSerialize] public ValueInput a { get; private set; } /// /// The second boolean. /// [DoNotSerialize] public ValueInput b { get; private set; } /// /// True if A and B are both true; false otherwise. /// [DoNotSerialize] [PortLabel("A & 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); } } }