Vector2Comparer.cs 739 B

1234567891011121314151617181920212223242526272829303132333435
  1. using System;
  2. using UnityEngine;
  3. namespace UnityTest
  4. {
  5. public class Vector2Comparer : VectorComparerBase<Vector2>
  6. {
  7. public enum CompareType
  8. {
  9. MagnitudeEquals,
  10. MagnitudeNotEquals
  11. }
  12. public CompareType compareType;
  13. public float floatingPointError = 0.0001f;
  14. protected override bool Compare(Vector2 a, Vector2 b)
  15. {
  16. switch (compareType)
  17. {
  18. case CompareType.MagnitudeEquals:
  19. return AreVectorMagnitudeEqual(a.magnitude,
  20. b.magnitude, floatingPointError);
  21. case CompareType.MagnitudeNotEquals:
  22. return !AreVectorMagnitudeEqual(a.magnitude,
  23. b.magnitude, floatingPointError);
  24. }
  25. throw new Exception();
  26. }
  27. public override int GetDepthOfSearch()
  28. {
  29. return 3;
  30. }
  31. }
  32. }