Edge.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using System;
  2. using UnityEngine;
  3. namespace UnityEditor.Graphing
  4. {
  5. [Serializable]
  6. class Edge : IEdge
  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. }
  51. }