MarkerItem.cs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. using System;
  2. using UnityEngine.Timeline;
  3. using Object = UnityEngine.Object;
  4. namespace UnityEditor.Timeline
  5. {
  6. class MarkerItem : ITimelineItem
  7. {
  8. readonly IMarker m_Marker;
  9. public IMarker marker
  10. {
  11. get { return m_Marker; }
  12. }
  13. public MarkerItem(IMarker marker)
  14. {
  15. m_Marker = marker;
  16. }
  17. public TrackAsset parentTrack
  18. {
  19. get { return m_Marker.parent; }
  20. set {}
  21. }
  22. public double start
  23. {
  24. get { return m_Marker.time; }
  25. set { m_Marker.time = value; }
  26. }
  27. public double end
  28. {
  29. get { return m_Marker.time; }
  30. }
  31. public double duration
  32. {
  33. get { return 0.0; }
  34. }
  35. public bool IsCompatibleWithTrack(TrackAsset track)
  36. {
  37. return true;
  38. }
  39. public void PushUndo(string operation)
  40. {
  41. var m = m_Marker as Object;
  42. if (m != null)
  43. {
  44. TimelineUndo.PushUndo(m, operation);
  45. }
  46. else
  47. {
  48. TimelineUndo.PushUndo(m_Marker.parent, operation);
  49. }
  50. }
  51. public TimelineItemGUI gui
  52. {
  53. get { return ItemToItemGui.GetGuiForMarker(m_Marker); }
  54. }
  55. public void Delete()
  56. {
  57. MarkerModifier.DeleteMarker(m_Marker);
  58. }
  59. public ITimelineItem CloneTo(TrackAsset parent, double time)
  60. {
  61. var item = new MarkerItem(MarkerModifier.CloneMarkerToParent(m_Marker, parent));
  62. item.start = time;
  63. return item;
  64. }
  65. protected bool Equals(MarkerItem otherMarker)
  66. {
  67. return Equals(m_Marker, otherMarker.m_Marker);
  68. }
  69. public override int GetHashCode()
  70. {
  71. return (m_Marker != null ? m_Marker.GetHashCode() : 0);
  72. }
  73. public override string ToString()
  74. {
  75. return m_Marker.ToString();
  76. }
  77. public bool Equals(ITimelineItem other)
  78. {
  79. return Equals((object)other);
  80. }
  81. public override bool Equals(object obj)
  82. {
  83. if (ReferenceEquals(null, obj)) return false;
  84. if (ReferenceEquals(this, obj)) return true;
  85. var other = obj as MarkerItem;
  86. return other != null && Equals(other);
  87. }
  88. }
  89. }