Пример #1
0
        public static void AlignClipsToHead(UnityEngine.Object[] objects)
        {
            Undo.RecordObjects(objects, "Align Clips to Head");

            List <double>       startTimeList = new List <double>();
            List <TimelineClip> clipList      = new List <TimelineClip>();

            foreach (var obj in objects)
            {
                var selectedClip = GetClip(obj);
                clipList.Add(selectedClip);
                startTimeList.Add(selectedClip.start);
            }

            double lowest = startTimeList.Min();

            foreach (var clip in clipList)
            {
                clip.start = lowest;
            }
            TimelineWindowUtils.GetWindow().Repaint();
        }
Пример #2
0
        public static void AlignClipsToTail(UnityEngine.Object[] objects)
        {
            Undo.RecordObjects(objects, "Align Clips to Tail");

            List <double>       startTimeList = new List <double>();
            List <TimelineClip> clipList      = new List <TimelineClip>();

            foreach (var obj in objects)
            {
                var selectedClip = GetClip(obj);
                clipList.Add(selectedClip);
                startTimeList.Add(selectedClip.end);
            }

            double highest = startTimeList.Max();

            foreach (var clip in clipList)
            {
                clip.start = highest - clip.duration;
            }
            TimelineWindowUtils.GetWindow().Repaint();
        }
Пример #3
0
        public static void SnapToNext(UnityEngine.Object[] objects)
        {
            Undo.RecordObjects(objects, "Snap To Next");
            List <TimelineClip> selectedClips = new List <TimelineClip>();

            for (int i = 0; i < objects.Length; i++)
            {
                var selectedClip = GetClip(objects[i]);
                selectedClips.Add(selectedClip);
            }

            selectedClips = selectedClips.OrderBy(c => c.start).ToList();
            selectedClips.Reverse();

            for (int i = 0; i < selectedClips.Count; i++)
            {
                var selectedClip  = selectedClips[i];
                var selectedTrack = TrackUtils.GetTrackBasedOnClip(selectedClip);
                var clipsInTrack  = (Array)selectedTrack.GetClips();
                var index         = Array.IndexOf(clipsInTrack, selectedClip);

                // if found
                if (index > -1)
                {
                    // and not the last clip in track
                    if (index != clipsInTrack.Length - 1)
                    {
                        var nextClip = clipsInTrack.GetValue(index + 1) as TimelineClip;
                        selectedClip.start = nextClip.start - selectedClip.duration;
                    }
                }
                else
                {
                    UnityEngine.Debug.LogWarning("Clip not found");
                }
            }
            TimelineWindowUtils.GetWindow().Repaint();
        }