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.

Edge.cs 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. using System;
  2. using UnityEngine;
  3. namespace UnityEditor.Graphing
  4. {
  5. [Serializable]
  6. class Edge : IEdge, IComparable<Edge>
  7. {
  8. [SerializeField]
  9. private SlotReference m_OutputSlot;
  10. [SerializeField]
  11. private SlotReference m_InputSlot;
  12. public Edge()
  13. { }
  14. public Edge(SlotReference outputSlot, SlotReference inputSlot)
  15. {
  16. m_OutputSlot = outputSlot;
  17. m_InputSlot = inputSlot;
  18. }
  19. public SlotReference outputSlot
  20. {
  21. get { return m_OutputSlot; }
  22. }
  23. public SlotReference inputSlot
  24. {
  25. get { return m_InputSlot; }
  26. }
  27. protected bool Equals(Edge other)
  28. {
  29. return Equals(m_OutputSlot, other.m_OutputSlot) && Equals(m_InputSlot, other.m_InputSlot);
  30. }
  31. public bool Equals(IEdge other)
  32. {
  33. return Equals(other as object);
  34. }
  35. public override bool Equals(object obj)
  36. {
  37. if (ReferenceEquals(null, obj)) return false;
  38. if (ReferenceEquals(this, obj)) return true;
  39. if (obj.GetType() != this.GetType()) return false;
  40. return Equals((Edge)obj);
  41. }
  42. public override int GetHashCode()
  43. {
  44. unchecked
  45. {
  46. // Can't make fields readonly due to Unity serialization
  47. return (m_OutputSlot.GetHashCode() * 397) ^ m_InputSlot.GetHashCode();
  48. }
  49. }
  50. public int CompareTo(Edge other)
  51. {
  52. if (ReferenceEquals(this, other)) return 0;
  53. if (ReferenceEquals(null, other)) return 1;
  54. var outputSlotComparison = m_OutputSlot.CompareTo(other.m_OutputSlot);
  55. if (outputSlotComparison != 0) return outputSlotComparison;
  56. return m_InputSlot.CompareTo(other.m_InputSlot);
  57. }
  58. }
  59. }