public static bool Split(IEnumerable <TimelineClip> clips, double splitTime, PlayableDirector director) { var result = false; foreach (var clip in clips) { if (clip.start >= splitTime) { continue; } if (clip.end <= splitTime) { continue; } UndoExtensions.RegisterClip(clip, L10n.Tr("Split Clip")); TimelineClip newClip = TimelineHelpers.Clone(clip, director, director, clip.start); clip.easeInDuration = 0; newClip.easeOutDuration = 0; SetStart(clip, splitTime, false); SetEnd(newClip, splitTime, false); // Sort produced by cloning clips on top of each other is unpredictable (it varies between mono runtimes) clip.GetParentTrack().SortClips(); result = true; } return(result); }
public static bool Split(PlayableDirector directorComponent, double splitTime, TimelineClip[] clips) { bool result = false; for (int i = 0; i < clips.Length; i++) { TimelineClip timelineClip = clips[i]; if (timelineClip.start <= splitTime) { if (timelineClip.start + timelineClip.duration >= splitTime) { TimelineUndo.PushUndo(timelineClip.parentTrack, "Split Clip"); double duration = timelineClip.duration; timelineClip.duration = splitTime - timelineClip.start; TimelineClip timelineClip2 = TimelineHelpers.Clone(timelineClip, directorComponent); timelineClip2.start = splitTime; timelineClip2.clipIn = timelineClip.duration * timelineClip.timeScale + timelineClip.clipIn; timelineClip2.duration = duration - timelineClip.duration; timelineClip.parentTrack.AddClip(timelineClip2); result = true; } } } return(result); }
internal static void RecursiveSubtrackClone(TrackAsset source, TrackAsset duplicate, PlayableDirector director, PlayableAsset assetOwner) { var subtracks = source.GetChildTracks(); foreach (var sub in subtracks) { var newSub = TimelineHelpers.Clone(duplicate, sub, director, assetOwner); duplicate.AddChild(newSub); RecursiveSubtrackClone(sub, newSub, director, assetOwner); // Call the custom editor on Create var customEditor = CustomTimelineEditorCache.GetTrackEditor(newSub); try { customEditor.OnCreate(newSub, sub); } catch (Exception e) { Debug.LogException(e); } // registration has to happen AFTER recursion TimelineUndo.RegisterCreatedObjectUndo(newSub, "Duplicate"); TimelineCreateUtilities.SaveAssetIntoObject(newSub, assetOwner); } }
public static TimelineClip Duplicate(this TimelineClip clip, PlayableDirector director) { TrackAsset parentTrack = clip.parentTrack; TimelineAsset timelineAsset = parentTrack.timelineAsset; TimelineClip result; if (parentTrack == null || timelineAsset == null) { result = null; } else { double num = ClipExtensions.FindClipInsertionTime(clip, parentTrack.clips); if (double.IsInfinity(num)) { result = null; } else { TimelineUndo.PushUndo(parentTrack, "Clone Clip"); TimelineClip timelineClip = TimelineHelpers.Clone(clip, director); timelineClip.start = num; clip.parentTrack.AddClip(timelineClip); clip.parentTrack.SortClips(); TrackExtensions.ComputeBlendsFromOverlaps(clip.parentTrack.clips); result = timelineClip; } } return(result); }
public static bool Split(TimelineClip[] clips, double splitTime, PlayableDirector director) { var result = false; foreach (var clip in clips) { if (clip.start >= splitTime) { continue; } if (clip.end <= splitTime) { continue; } TimelineUndo.PushUndo(clip.parentTrack, "Split Clip"); TimelineClip newClip = TimelineHelpers.Clone(clip, director, director, clip.start); SetStart(clip, splitTime); SetEnd(newClip, splitTime, false); // Sort produced by cloning clips on top of each other is unpredictable (it varies between mono runtimes) clip.parentTrack.SortClips(); result = true; } return(result); }
public static TimelineClip DuplicateAtTime(this TimelineClip clip, TrackAsset track, double time, PlayableDirector director) { TimelineUndo.PushUndo(track, "Clone Clip"); TimelineClip timelineClip = TimelineHelpers.Clone(clip, director); timelineClip.start = time; timelineClip.parentTrack = track; track.AddClip(timelineClip); track.SortClips(); TrackExtensions.ComputeBlendsFromOverlaps(track.clips); return(timelineClip); }
internal static void RecursiveSubtrackClone(TrackAsset source, TrackAsset duplicate, PlayableDirector director) { List <TrackAsset> subTracks = source.subTracks; foreach (TrackAsset current in subTracks) { TrackAsset trackAsset = TimelineHelpers.Clone(duplicate, current, director); duplicate.AddChild(trackAsset); TrackExtensions.RecursiveSubtrackClone(current, trackAsset, director); Undo.RegisterCreatedObjectUndo(trackAsset, "Duplicate"); TimelineCreateUtilities.SaveAssetIntoObject(trackAsset, source); } }
internal static void RecursiveSubtrackClone(TrackAsset source, TrackAsset duplicate, PlayableDirector director, PlayableAsset assetOwner) { var subtracks = source.GetChildTracks(); foreach (var sub in subtracks) { var newSub = TimelineHelpers.Clone(duplicate, sub, director, assetOwner); duplicate.AddChild(newSub); RecursiveSubtrackClone(sub, newSub, director, assetOwner); // registration has to happen AFTER recursion TimelineUndo.RegisterCreatedObjectUndo(newSub, "Duplicate"); TimelineCreateUtilities.SaveAssetIntoObject(newSub, assetOwner); } }
internal static bool Duplicate(this TrackAsset track, PlayableDirector director, TimelineAsset destinationTimeline = null) { bool result; if (track == null) { result = false; } else { if (destinationTimeline == track.timelineAsset) { destinationTimeline = null; } TimelineAsset timelineAsset = track.parent as TimelineAsset; TrackAsset trackAsset = track.parent as TrackAsset; if (timelineAsset == null && trackAsset == null) { Debug.LogWarning("Cannot duplicate track because it is not parented to known type"); result = false; } else { PlayableAsset playableAsset = destinationTimeline ?? track.parent; TrackAsset trackAsset2 = TimelineHelpers.Clone(playableAsset, track, director); TrackExtensions.RecursiveSubtrackClone(track, trackAsset2, director); Undo.RegisterCreatedObjectUndo(trackAsset2, "Duplicate"); TimelineCreateUtilities.SaveAssetIntoObject(trackAsset2, playableAsset); TimelineUndo.PushUndo(playableAsset, "Duplicate"); if (destinationTimeline != null) { destinationTimeline.AddTrackInternal(trackAsset2); } else if (timelineAsset != null) { TrackExtensions.ReparentTracks(new List <TrackAsset> { trackAsset2 }, timelineAsset, track, false); } else { trackAsset.AddChildAfter(trackAsset2, track); } result = true; } } return(result); }
public static TrackAsset Clone(PlayableAsset parent, TrackAsset trackAsset, PlayableDirector directorInstance) { TrackAsset result; if (trackAsset == null) { result = null; } else { TimelineAsset timelineAsset = trackAsset.timelineAsset; if (timelineAsset == null) { result = null; } else { TrackAsset trackAsset2 = Object.Instantiate <TrackAsset>(trackAsset); trackAsset2.SetClips(new List <TimelineClip>()); trackAsset2.parent = parent; trackAsset2.subTracks = new List <TrackAsset>(); string[] array = (from x in timelineAsset.flattenedTracks select x.get_name()).ToArray <string>(); trackAsset2.set_name(ObjectNames.GetUniqueName(array, trackAsset.get_name())); if (trackAsset.animClip != null) { trackAsset2.animClip = TimelineHelpers.CloneAnimationClipIfRequired(trackAsset.animClip, trackAsset); } TimelineClip[] clips = trackAsset.clips; for (int i = 0; i < clips.Length; i++) { TimelineClip clip = clips[i]; TimelineClip timelineClip = TimelineHelpers.Clone(clip, directorInstance); timelineClip.parentTrack = trackAsset2; trackAsset2.AddClip(timelineClip); } trackAsset2.SetCollapsed(trackAsset.GetCollapsed()); if (SelectionManager.Contains(trackAsset)) { SelectionManager.Remove(trackAsset); SelectionManager.Add(trackAsset2); } result = trackAsset2; } } return(result); }
static void RecursiveSubtrackClone(TrackAsset source, TrackAsset duplicate, IExposedPropertyTable sourceTable, IExposedPropertyTable destTable, PlayableAsset assetOwner) { var subtracks = source.GetChildTracks(); foreach (var sub in subtracks) { var newSub = TimelineHelpers.Clone(duplicate, sub, sourceTable, destTable, assetOwner); duplicate.AddChild(newSub); RecursiveSubtrackClone(sub, newSub, sourceTable, destTable, assetOwner); // Call the custom editor on Create var customEditor = CustomTimelineEditorCache.GetTrackEditor(newSub); customEditor.OnCreate_Safe(newSub, sub); // registration has to happen AFTER recursion TimelineCreateUtilities.SaveAssetIntoObject(newSub, assetOwner); TimelineUndo.RegisterCreatedObjectUndo(newSub, L10n.Tr("Duplicate")); } }
ClipItem CopyItem(ClipItem clipItem) { var newClip = TimelineHelpers.Clone(clipItem.clip, TimelineWindow.instance.state.editSequence.director, rootTimeline); return(new ClipItem(newClip)); }
public ITimelineItem CloneTo(TrackAsset parent, double time) { return(new ClipItem(TimelineHelpers.Clone(m_Clip, TimelineEditor.inspectedDirector, TimelineEditor.inspectedDirector, time, parent))); }
internal static TrackAsset Duplicate(this TrackAsset track, PlayableDirector director, TimelineAsset destinationTimeline = null) { if (track == null) { return(null); } // if the destination is us, clear to avoid bad parenting (case 919421) if (destinationTimeline == track.timelineAsset) { destinationTimeline = null; } var timelineParent = track.parent as TimelineAsset; var trackParent = track.parent as TrackAsset; if (timelineParent == null && trackParent == null) { Debug.LogWarning("Cannot duplicate track because it is not parented to known type"); return(null); } // Determine who the final parent is. If we are pasting into another track, it's always the timeline. // Otherwise it's the original parent PlayableAsset finalParent = destinationTimeline != null ? destinationTimeline : track.parent; // grab the list of tracks to generate a name from (923360) to get the list of names // no need to do this part recursively var finalTrackParent = finalParent as TrackAsset; var finalTimelineAsset = finalParent as TimelineAsset; var otherTracks = (finalTimelineAsset != null) ? finalTimelineAsset.trackObjects : finalTrackParent.subTracksObjects; // Important to create the new objects before pushing the original undo, or redo breaks the // sequence var newTrack = TimelineHelpers.Clone(finalParent, track, director, finalParent); newTrack.name = TimelineCreateUtilities.GenerateUniqueActorName(otherTracks, newTrack.name); RecursiveSubtrackClone(track, newTrack, director, finalParent); TimelineUndo.RegisterCreatedObjectUndo(newTrack, "Duplicate"); TimelineCreateUtilities.SaveAssetIntoObject(newTrack, finalParent); TimelineUndo.PushUndo(finalParent, "Duplicate"); if (destinationTimeline != null) // other timeline { destinationTimeline.AddTrackInternal(newTrack); } else if (timelineParent != null) // this timeline, no parent { ReparentTracks(new List <TrackAsset> { newTrack }, timelineParent, timelineParent.GetRootTracks().Last(), false); } else // this timeline, with parent { trackParent.AddChild(newTrack); } // Call the custom editor. this check prevents the call when copying to the clipboard if (destinationTimeline == null || destinationTimeline == TimelineEditor.inspectedAsset) { var customEditor = CustomTimelineEditorCache.GetTrackEditor(newTrack); try { customEditor.OnCreate(newTrack, track); } catch (Exception e) { Debug.LogException(e); } } return(newTrack); }
public ITimelineItem CloneTo(TrackAsset parent, double time) { return(new ClipItem(TimelineHelpers.Clone(m_Clip, TimelineWindow.instance.state.editSequence.director, time, parent))); }