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.

40 lines
828 B

  1. using UnityEngine;
  2. namespace AmplifyShaderEditor
  3. {
  4. public static class RectExtension
  5. {
  6. private static Rect ValidateBoundaries( this Rect thisRect )
  7. {
  8. if ( thisRect.yMin > thisRect.yMax )
  9. {
  10. float yMin = thisRect.yMin;
  11. thisRect.yMin = thisRect.yMax;
  12. thisRect.yMax = yMin;
  13. }
  14. if ( thisRect.xMin > thisRect.xMax )
  15. {
  16. float xMin = thisRect.xMin;
  17. thisRect.xMin = thisRect.xMax;
  18. thisRect.xMax = xMin;
  19. }
  20. return thisRect;
  21. }
  22. public static bool Includes( this Rect thisRect , Rect other )
  23. {
  24. thisRect = thisRect.ValidateBoundaries();
  25. other = other.ValidateBoundaries();
  26. if ( other.xMin >= thisRect.xMin && other.xMax <= thisRect.xMax )
  27. {
  28. if ( other.yMin >= thisRect.yMin && other.yMax <= thisRect.yMax )
  29. {
  30. return true;
  31. }
  32. }
  33. return false;
  34. }
  35. }
  36. }