TimelineClipGroup.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using System.Collections.Generic;
  2. using System.Linq;
  3. using UnityEngine;
  4. using UnityEngine.Timeline;
  5. namespace UnityEditor.Timeline
  6. {
  7. class TimelineClipGroup
  8. {
  9. readonly TimelineClip[] m_Clips;
  10. readonly TimelineClip m_LeftMostClip;
  11. readonly TimelineClip m_RightMostClip;
  12. public TimelineClip[] clips
  13. {
  14. get { return m_Clips; }
  15. }
  16. public double start
  17. {
  18. get { return m_LeftMostClip.start; }
  19. set
  20. {
  21. var offset = value - m_LeftMostClip.start;
  22. foreach (var clip in m_Clips)
  23. clip.start += offset;
  24. }
  25. }
  26. public double end
  27. {
  28. get { return m_RightMostClip.end; }
  29. }
  30. public TimelineClipGroup(IEnumerable<TimelineClip> clips)
  31. {
  32. Debug.Assert(clips != null && clips.Any());
  33. m_Clips = clips.ToArray();
  34. m_LeftMostClip = null;
  35. m_RightMostClip = null;
  36. foreach (var clip in m_Clips)
  37. {
  38. if (m_LeftMostClip == null || clip.start < m_LeftMostClip.start)
  39. m_LeftMostClip = clip;
  40. if (m_RightMostClip == null || clip.end > m_RightMostClip.end)
  41. m_RightMostClip = clip;
  42. }
  43. }
  44. }
  45. }