No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Negate.cs 956B

12345678910111213141516171819202122232425262728293031323334353637
  1. namespace Unity.VisualScripting
  2. {
  3. /// <summary>
  4. /// Inverts the value of a boolean.
  5. /// </summary>
  6. [UnitCategory("Logic")]
  7. [UnitOrder(3)]
  8. public sealed class Negate : Unit
  9. {
  10. /// <summary>
  11. /// The input boolean.
  12. /// </summary>
  13. [DoNotSerialize]
  14. [PortLabel("X")]
  15. public ValueInput input { get; private set; }
  16. /// <summary>
  17. /// True if the input is false, false if the input is true.
  18. /// </summary>
  19. [DoNotSerialize]
  20. [PortLabel("~X")]
  21. public ValueOutput output { get; private set; }
  22. protected override void Definition()
  23. {
  24. input = ValueInput<bool>(nameof(input));
  25. output = ValueOutput(nameof(output), Operation).Predictable();
  26. Requirement(input, output);
  27. }
  28. public bool Operation(Flow flow)
  29. {
  30. return !flow.GetValue<bool>(input);
  31. }
  32. }
  33. }