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