ClipItem.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. using System;
  2. using UnityEngine.Timeline;
  3. namespace UnityEditor.Timeline
  4. {
  5. class ClipItem : IBlendable, ITrimmable
  6. {
  7. readonly TimelineClip m_Clip;
  8. public TimelineClip clip
  9. {
  10. get { return m_Clip; }
  11. }
  12. public ClipItem(TimelineClip clip)
  13. {
  14. m_Clip = clip;
  15. }
  16. public TrackAsset parentTrack
  17. {
  18. get { return m_Clip.parentTrack; }
  19. set { m_Clip.parentTrack = value; }
  20. }
  21. public double start
  22. {
  23. get { return m_Clip.start; }
  24. set { m_Clip.start = value; }
  25. }
  26. public double end
  27. {
  28. get { return m_Clip.end; }
  29. }
  30. public double duration
  31. {
  32. get { return m_Clip.duration; }
  33. }
  34. public bool IsCompatibleWithTrack(TrackAsset track)
  35. {
  36. return track.IsCompatibleWithClip(m_Clip);
  37. }
  38. public void PushUndo(string operation)
  39. {
  40. TimelineUndo.PushUndo(m_Clip.parentTrack, operation);
  41. }
  42. public TimelineItemGUI gui
  43. {
  44. get { return ItemToItemGui.GetGuiForClip(m_Clip); }
  45. }
  46. public bool supportsBlending
  47. {
  48. get { return m_Clip.SupportsBlending(); }
  49. }
  50. public bool hasLeftBlend
  51. {
  52. get { return m_Clip.hasBlendIn; }
  53. }
  54. public bool hasRightBlend
  55. {
  56. get { return m_Clip.hasBlendOut; }
  57. }
  58. public double leftBlendDuration
  59. {
  60. get { return m_Clip.hasBlendIn ? m_Clip.blendInDuration : m_Clip.easeInDuration; }
  61. }
  62. public double rightBlendDuration
  63. {
  64. get { return m_Clip.hasBlendOut ? m_Clip.blendOutDuration : m_Clip.easeOutDuration; }
  65. }
  66. public void SetStart(double time)
  67. {
  68. ClipModifier.SetStart(m_Clip, time);
  69. }
  70. public void SetEnd(double time, bool affectTimeScale)
  71. {
  72. ClipModifier.SetEnd(m_Clip, time, affectTimeScale);
  73. }
  74. public void Delete()
  75. {
  76. EditorClipFactory.RemoveEditorClip(m_Clip);
  77. ClipModifier.Delete(m_Clip.parentTrack.timelineAsset, m_Clip);
  78. }
  79. public void TrimStart(double time)
  80. {
  81. ClipModifier.TrimStart(m_Clip, time);
  82. }
  83. public void TrimEnd(double time)
  84. {
  85. ClipModifier.TrimEnd(m_Clip, time);
  86. }
  87. public ITimelineItem CloneTo(TrackAsset parent, double time)
  88. {
  89. return new ClipItem(TimelineHelpers.Clone(m_Clip, TimelineEditor.inspectedDirector, TimelineEditor.inspectedDirector, time, parent));
  90. }
  91. public override string ToString()
  92. {
  93. return m_Clip.ToString();
  94. }
  95. public bool Equals(ClipItem otherClip)
  96. {
  97. if (ReferenceEquals(null, otherClip)) return false;
  98. if (ReferenceEquals(this, otherClip)) return true;
  99. return Equals(m_Clip, otherClip.m_Clip);
  100. }
  101. public override int GetHashCode()
  102. {
  103. return (m_Clip != null ? m_Clip.GetHashCode() : 0);
  104. }
  105. public bool Equals(ITimelineItem other)
  106. {
  107. return Equals((object)other);
  108. }
  109. public override bool Equals(object obj)
  110. {
  111. if (ReferenceEquals(null, obj)) return false;
  112. if (ReferenceEquals(this, obj)) return true;
  113. var other = obj as ClipItem;
  114. return other != null && Equals(other);
  115. }
  116. }
  117. }