Нет описания
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

NotApproximatelyEqual.cs 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using System;
  2. using UnityEngine;
  3. namespace Unity.VisualScripting
  4. {
  5. /// <summary>
  6. /// Compares two numbers to determine if they are not approximately equal (disregarding floating point precision errors).
  7. /// </summary>
  8. [UnitCategory("Logic")]
  9. [UnitShortTitle("Not Equal")]
  10. [UnitSubtitle("(Approximately)")]
  11. [UnitOrder(8)]
  12. [Obsolete("Use the Not Equal node with Numeric enabled instead.")]
  13. public sealed class NotApproximatelyEqual : Unit
  14. {
  15. /// <summary>
  16. /// The first number.
  17. /// </summary>
  18. [DoNotSerialize]
  19. public ValueInput a { get; private set; }
  20. /// <summary>
  21. /// The second number.
  22. /// </summary>
  23. [DoNotSerialize]
  24. public ValueInput b { get; private set; }
  25. /// <summary>
  26. /// Whether A is not approximately equal to B.
  27. /// </summary>
  28. [DoNotSerialize]
  29. [PortLabel("A \u2249 B")]
  30. public ValueOutput notEqual { get; private set; }
  31. protected override void Definition()
  32. {
  33. a = ValueInput<float>(nameof(a));
  34. b = ValueInput<float>(nameof(b), 0);
  35. notEqual = ValueOutput(nameof(notEqual), Comparison).Predictable();
  36. Requirement(a, notEqual);
  37. Requirement(b, notEqual);
  38. }
  39. public bool Comparison(Flow flow)
  40. {
  41. return !Mathf.Approximately(flow.GetValue<float>(a), flow.GetValue<float>(b));
  42. }
  43. }
  44. }