Edge.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using UnityEngine;
  2. using System;
  3. namespace UnityEditor.U2D.Animation
  4. {
  5. [Serializable]
  6. internal struct Edge
  7. {
  8. [SerializeField]
  9. int m_Index1;
  10. [SerializeField]
  11. int m_Index2;
  12. public int index1
  13. {
  14. get { return m_Index1; }
  15. set { m_Index1 = value; }
  16. }
  17. public int index2
  18. {
  19. get { return m_Index2; }
  20. set { m_Index2 = value; }
  21. }
  22. public Edge(int inIndex1, int inIndex2)
  23. {
  24. m_Index1 = inIndex1;
  25. m_Index2 = inIndex2;
  26. }
  27. public bool Contains(int index)
  28. {
  29. return index1 == index || index2 == index;
  30. }
  31. public static bool operator==(Edge lhs, Edge rhs)
  32. {
  33. return lhs.Equals(rhs);
  34. }
  35. public static bool operator!=(Edge lhs, Edge rhs)
  36. {
  37. return !lhs.Equals(rhs);
  38. }
  39. public override bool Equals(System.Object obj)
  40. {
  41. if (obj == null || GetType() != obj.GetType())
  42. return false;
  43. Edge p = (Edge)obj;
  44. return (index1 == p.index1) && (index2 == p.index2) || (index1 == p.index2) && (index2 == p.index1);
  45. }
  46. public override int GetHashCode()
  47. {
  48. return index1.GetHashCode() ^ index2.GetHashCode();
  49. }
  50. }
  51. }