void CalculateLoopRects(Rect trackRect, WindowState state) { if (!m_ClipViewDirty) { return; } m_LoopRects.Clear(); if (clip.duration < WindowState.kTimeEpsilon) { return; } var times = TimelineHelpers.GetLoopTimes(clip); var loopDuration = TimelineHelpers.GetLoopDuration(clip); m_MinLoopIndex = -1; // we have a hold, no need to compute all loops if (!supportsLooping) { if (times.Length > 1) { var t = times[1]; float loopTime = (float)(clip.duration - t); m_LoopRects.Add(ProjectRectOnTimeline(new Rect((float)(t + clip.start), 0, loopTime, 0), trackRect, state)); } return; } var range = state.timeAreaShownRange; var visibleStartTime = range.x - clip.start; var visibleEndTime = range.y - clip.start; for (int i = 1; i < times.Length; i++) { var t = times[i]; // don't draw off screen loops if (t > visibleEndTime) { break; } float loopTime = Mathf.Min((float)(clip.duration - t), (float)loopDuration); var loopEnd = t + loopTime; if (loopEnd < visibleStartTime) { continue; } m_LoopRects.Add(ProjectRectOnTimeline(new Rect((float)(t + clip.start), 0, loopTime, 0), trackRect, state)); if (m_MinLoopIndex == -1) { m_MinLoopIndex = i; } } }
public static bool CompleteLastLoop(TimelineClip[] clips) { for (int i = 0; i < clips.Length; i++) { TimelineClip timelineClip = clips[i]; if (TimelineHelpers.HasUsableAssetDuration(timelineClip)) { double[] loopTimes = TimelineHelpers.GetLoopTimes(timelineClip); double loopDuration = TimelineHelpers.GetLoopDuration(timelineClip); TimelineUndo.PushUndo(timelineClip.parentTrack, "Complete Clip Last Loop"); timelineClip.duration = timelineClip.start + loopTimes.LastOrDefault <double>() + loopDuration; } } return(true); }
public static bool TrimLastLoop(TimelineClip[] clips) { for (int i = 0; i < clips.Length; i++) { TimelineClip timelineClip = clips[i]; if (TimelineHelpers.HasUsableAssetDuration(timelineClip)) { double[] loopTimes = TimelineHelpers.GetLoopTimes(timelineClip); double loopDuration = TimelineHelpers.GetLoopDuration(timelineClip); double num = timelineClip.duration - loopTimes.FirstOrDefault <double>(); if (loopDuration > 0.0) { num = (timelineClip.duration - loopTimes.FirstOrDefault <double>()) / loopDuration; } int num2 = Mathf.FloorToInt((float)num); if (num2 > 0) { TimelineUndo.PushUndo(timelineClip.parentTrack, "Trim Clip Last Loop"); timelineClip.duration = loopTimes.FirstOrDefault <double>() + (double)num2 * loopDuration; } } } return(true); }