static bool SelectFirstClipStartingFrom(TrackAsset track) { List <TrackAsset> visibleTracks = GetVisibleTracks().Select(x => x.track).ToList(); int idx = visibleTracks.IndexOf(track); ITimelineItem item = null; for (int i = idx; i < visibleTracks.Count; ++i) { var items = visibleTracks[i].GetItems().OfType <ClipItem>(); if (!items.Any() || visibleTracks[i].lockedInHierarchy) { continue; } item = items.First(); break; } if (item != null) { SelectionManager.SelectOnly(item); TimelineHelpers.FrameItems(new[] { item }); return(true); } return(false); }
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); }
public static bool SelectRightItem(bool shift = false) { if (ClipAreaActive()) { var items = SelectionManager.SelectedItems().ToList(); var clipOnly = FilterItems(ref items); var item = items.Last(); var next = item.NextItem(clipOnly); if (next != null) { if (shift) { if (SelectionManager.Contains(next)) { SelectionManager.Remove(item); } SelectionManager.Add(next); } else { SelectionManager.SelectOnly(next); } TimelineHelpers.FrameItems(new[] { next }); return(true); } } return(false); }
private static void AddAssetOnTrack(Type typeOfClip, TrackAsset track, ITimelineState state) { state.AddStartFrameDelegate(delegate(ITimelineState istate, Event currentEvent) { ObjectSelector.get_get().Show(null, typeOfClip, null, false); ObjectSelector.get_get().objectSelectorID = 0; ObjectSelector.get_get().set_searchFilter(""); return(true); }); state.AddStartFrameDelegate(delegate(ITimelineState istate, Event currentEvent) { bool result; if (currentEvent.get_commandName() == "ObjectSelectorClosed") { AnimationTrack animationTrack = track as AnimationTrack; if (animationTrack && !animationTrack.inClipMode) { animationTrack.ConvertToClipMode(); } TimelineClip timelineClip = TimelineHelpers.CreateClipOnTrack(EditorGUIUtility.GetObjectPickerObject(), track, istate, TimelineHelpers.sInvalidMousePosition); if (timelineClip != null && timelineClip.asset != null) { TimelineCreateUtilities.SaveAssetIntoObject(timelineClip.asset, track); } result = true; } else { result = false; } return(result); }); }
static void PasteTracks() { var trackData = TimelineEditor.clipboard.GetTracks().ToList(); if (trackData.Any()) { SelectionManager.RemoveTimelineSelection(); } foreach (var track in trackData) { var newTrack = track.item.Duplicate(TimelineEditor.clipboard.exposedPropertyTable, TimelineEditor.inspectedDirector, TimelineEditor.inspectedAsset); if (track.binding != null) { TimelineHelpers.Bind(newTrack, track.binding, TimelineEditor.inspectedDirector); } SelectionManager.Add(newTrack); foreach (var childTrack in newTrack.GetFlattenedChildTracks()) { SelectionManager.Add(childTrack); } if (track.parent != null && track.parent.timelineAsset == TimelineEditor.inspectedAsset) { TrackExtensions.ReparentTracks(new List <TrackAsset> { newTrack }, track.parent, track.item); } } }
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 TimelineClip CreateClip(this TrackAsset track, double time) { var attr = track.GetType().GetCustomAttributes(typeof(TrackClipTypeAttribute), true); if (attr.Length == 0) { return(null); } if (TimelineWindow.instance.state == null) { return(null); } if (attr.Length == 1) { var clipClass = (TrackClipTypeAttribute)attr[0]; var clip = TimelineHelpers.CreateClipOnTrack(clipClass.inspectedType, track, TimelineWindow.instance.state); clip.start = time; return(clip); } return(null); }
static void AddTrackMenuCommands(GenericMenu newTrackMenu, TrackAsset parentTrack, TimelineGroupGUI parentGroup, WindowState state) { // Add Group or SubGroup var title = parentTrack == null?L10n.Tr("Track Group") : L10n.Tr("Track Sub-Group"); var disabled = (parentTrack != null && parentTrack.lockedInHierarchy) || state.editSequence.isReadOnly; GenericMenu.MenuFunction command = () => { SelectionManager.Clear(); TimelineHelpers.CreateTrack <GroupTrack>(parentTrack, title); }; AddCommandToMenu(newTrackMenu, title, command, !disabled); newTrackMenu.AddSeparator(""); var allTypes = TypeUtility.AllTrackTypes().Where(x => x != typeof(GroupTrack) && !TypeUtility.IsHiddenInMenu(x)).ToList(); var builtIn = allTypes.Where(x => x.Assembly.Equals(typeof(TimelineAsset).Assembly)).OrderBy(i => i.FullName).ToList(); var customTypes = allTypes.Except(builtIn).ToList(); foreach (var t in builtIn) { AddNewTrackMenuCommand(newTrackMenu, parentTrack, parentGroup, t, state); } if (builtIn.Any() && customTypes.Any()) { newTrackMenu.AddSeparator(""); } foreach (var t in customTypes) { AddNewTrackMenuCommand(newTrackMenu, parentTrack, parentGroup, t, state); } }
public static void ShowItemContextMenu(Vector2 mousePosition) { var menu = new GenericMenu(); var state = TimelineWindow.instance.state; TimelineAction.AddToMenu(menu, state, mousePosition); if (SelectionManager.SelectedClips().Any()) { ItemAction <TimelineClip> .AddToMenu(menu, state); } if (SelectionManager.SelectedMarkers().Any()) { ItemAction <IMarker> .AddToMenu(menu, state); } var clipGUI = PickerUtils.PickedLayerableOfType <TimelineClipGUI>(); if (clipGUI != null && clipGUI.drawer != null) { var clips = SelectionManager.SelectedClips().ToArray(); if (clips.Length > 0) { clipGUI.drawer.OnBuildClipContextMenu(menu, clips, state); AddMarkerMenuCommands(menu, clipGUI.clip.parentTrack, TimelineHelpers.GetCandidateTime(state, mousePosition)); } } menu.ShowAsContext(); }
static void AddNewTrackMenuCommand(GenericMenu menu, TrackAsset parentTrack, TimelineGroupGUI parentGroup, Type type, WindowState state) { GenericMenu.MenuFunction2 lastMethod = trackType => { SelectionManager.Clear(); TimelineHelpers.CreateTrack((Type)trackType, parentTrack); }; var category = TimelineHelpers.GetTrackCategoryName(type); if (!string.IsNullOrEmpty(category)) { category += "/"; } var name = category + TimelineHelpers.GetTrackMenuName(type); var disabled = (parentTrack != null && parentTrack.lockedInHierarchy) || state.editSequence.isReadOnly; bool addenu = true; var attr = Attribute.GetCustomAttribute(type, typeof(TrackAttribute)) as TrackAttribute; if (attr != null) { addenu = !attr.onlyInSub; } if (addenu) { AddCommandToMenu(menu, name, lastMethod, type, !disabled); } }
public static void AddClipMenuCommands(GenericMenu menu, TrackAsset trackAsset, double candidateTime) { var assetTypes = TypeUtility.GetPlayableAssetsHandledByTrack(trackAsset.GetType()); var visibleAssetTypes = TypeUtility.GetVisiblePlayableAssetsHandledByTrack(trackAsset.GetType()); if (assetTypes.Any() || visibleAssetTypes.Any()) { menu.AddSeparator(string.Empty); } // skips the name if there is only a single type var commandNameTemplate = assetTypes.Count() == 1 ? Styles.addSingleItemFromAssetTemplate : Styles.addItemFromAssetTemplate; foreach (var assetType in assetTypes) { Action <Object> onObjectChanged = obj => { if (obj != null) { TimelineHelpers.CreateClipOnTrack(assetType, obj, trackAsset, candidateTime); } }; AddItemFromAssetCommands(menu, commandNameTemplate, assetType, onObjectChanged, !trackAsset.lockedInHierarchy && !TimelineWindow.instance.state.editSequence.isReadOnly); } foreach (var assetType in visibleAssetTypes) { var commandName = string.Format(Styles.addItemTemplate, TypeUtility.GetDisplayName(assetType)); GenericMenu.MenuFunction command = () => { TimelineHelpers.CreateClipOnTrack(assetType, trackAsset, candidateTime); }; AddCommandToMenu(menu, commandName, command, !trackAsset.lockedInHierarchy && !TimelineWindow.instance.state.editSequence.isReadOnly); } }
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 void BuildTrackContextMenu(List <MenuActionItem> items, Vector2?mousePosition) { var tracks = SelectionManager.SelectedTracks().ToArray(); if (tracks.Length == 0) { return; } ActionManager.GetMenuEntries(ActionManager.TimelineActions, mousePosition, items); ActionManager.GetMenuEntries(ActionManager.TrackActions, items); AddLayeredTrackCommands(items, tracks); var first = tracks.First().GetType(); var allTheSame = tracks.All(t => t.GetType() == first); if (allTheSame) { if (first != typeof(GroupTrack)) { var candidateTime = TimelineHelpers.GetCandidateTime(mousePosition, tracks); AddClipMenuCommands(items, tracks, candidateTime); AddMarkerMenuCommands(items, tracks, candidateTime); } else { BuildNewTracksContextMenu(items, tracks, TimelineWindow.instance.state, Styles.addItemTemplate); } } }
public override bool Execute(TimelineWindow.TimelineState state) { bool result; if (state.IsEditingASubItem()) { result = false; } else if (SelectionManager.Count() == 0) { result = false; } else { bool flag = false; foreach (TimelineClip current in SelectionManager.SelectedItems <TimelineClip>()) { flag |= TimelineHelpers.NudgeClip(current, state, 1.0); } if (flag) { state.Evaluate(); } result = true; } return(result); }
public static bool MatchContent(TimelineClip clip) { if (clip.asset == null) { return(false); } TimelineUndo.PushUndo(clip.parentTrack, "Match Clip Content"); var newStartCandidate = clip.start - clip.clipIn / clip.timeScale; var newStart = newStartCandidate < 0.0 ? 0.0 : newStartCandidate; TrimClipWithEditMode(clip, TrimEdge.Start, newStart); // In case resetting the start was blocked by edit mode or timeline start, we do the best we can clip.clipIn = (clip.start - newStartCandidate) * clip.timeScale; if (TimelineHelpers.HasUsableAssetDuration(clip)) { var duration = TimelineHelpers.GetLoopDuration(clip); var offset = (clip.clipIn / clip.timeScale) % duration; TrimClipWithEditMode(clip, TrimEdge.End, clip.start - offset + duration); } return(true); }
public static TimelineClip Clone(TimelineClip clip, PlayableDirector directorInstance) { EditorClip editorClip = EditorItemFactory.GetEditorClip(clip); TimelineClip clip2 = Object.Instantiate <EditorClip>(editorClip).clip; SelectionManager.Remove(clip2); clip2.parentTrack = null; clip2.ClearAnimatedParameterCurves(); if (clip.curves != null) { AnimatedParameterExtensions.CreateCurvesIfRequired(clip2, clip.parentTrack); EditorUtility.CopySerialized(clip.curves, clip2.curves); } ScriptableObject scriptableObject = clip2.asset as ScriptableObject; if (scriptableObject != null && clip2.asset is IPlayableAsset) { ScriptableObject scriptableObject2 = TimelineHelpers.CloneReferencedPlayableAsset(scriptableObject, directorInstance); TimelineHelpers.SaveCloneToOriginalAsset(scriptableObject, scriptableObject2); clip2.asset = scriptableObject2; AnimationPlayableAsset animationPlayableAsset = scriptableObject2 as AnimationPlayableAsset; if (clip2.recordable && animationPlayableAsset != null && animationPlayableAsset.clip != null) { clip2.displayName = animationPlayableAsset.clip.get_name(); } } return(clip2); }
static void FixLoops(TimelineClip clip, bool completeLastLoop) { if (!TimelineHelpers.HasUsableAssetDuration(clip)) { return; } var loopDuration = TimelineHelpers.GetLoopDuration(clip); var firstLoopDuration = loopDuration - clip.clipIn * (1.0 / clip.timeScale); // Making sure we don't trim to zero if (!completeLastLoop && firstLoopDuration > clip.duration) { return; } var numLoops = (clip.duration - firstLoopDuration) / loopDuration; var numCompletedLoops = Math.Floor(numLoops); if (!(numCompletedLoops < numLoops)) { return; } if (completeLastLoop) { numCompletedLoops += 1; } var newEnd = clip.start + firstLoopDuration + loopDuration * numCompletedLoops; TimelineUndo.PushUndo(clip.parentTrack, "Trim Clip Last Loop"); TrimClipWithEditMode(clip, TrimEdge.End, newEnd); }
public static TrackType[] GetTrackTypeHandle(Type toBeHandled) { Type[] array = (from assemblyType in EditorAssemblies.get_loadedTypes() where assemblyType.IsSubclassOf(typeof(TrackAsset)) select assemblyType).ToArray <Type>(); List <TrackType> list = new List <TrackType>(); Type[] array2 = array; for (int i = 0; i < array2.Length; i++) { Type type = array2[i]; object[] customAttributes = type.GetCustomAttributes(typeof(TrackClipTypeAttribute), true); object[] array3 = customAttributes; for (int j = 0; j < array3.Length; j++) { object obj = array3[j]; Type inspectedType = ((TrackClipTypeAttribute)obj).inspectedType; if (inspectedType == toBeHandled || inspectedType.IsAssignableFrom(toBeHandled)) { TrackType item = new TrackType(type, TimelineHelpers.GetMediaTypeFromType(type)); list.Add(item); } } } if (toBeHandled == typeof(MonoScript)) { list.Add(new TrackType(typeof(PlayableTrack), TimelineHelpers.GetMediaTypeFromType(typeof(PlayableTrack)))); } return(list.ToArray()); }
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 double[] GetLoopTimes(TimelineClip clip) { double[] result; if (!TimelineHelpers.HasUsableAssetDuration(clip)) { result = new double[] { -clip.clipIn / clip.timeScale }; } else { List <double> list = new List <double>(); double loopDuration = TimelineHelpers.GetLoopDuration(clip); if (loopDuration <= TimeUtility.kTimeEpsilon) { result = new double[0]; } else { double num = -clip.clipIn / clip.timeScale; double num2 = num + loopDuration; list.Add(num); while (num2 < clip.duration - TimelineWindow.TimelineState.kTimeEpsilon) { list.Add(num2); num2 += loopDuration; } result = list.ToArray(); } } return(result); }
void HandleDragAndDrop() { if (TimelineWindow.instance.state.editSequence.isReadOnly) { return; } if (Event.current == null || Event.current.type != EventType.DragUpdated && Event.current.type != EventType.DragPerform && Event.current.type != EventType.DragExited) { return; } timeline.CreateMarkerTrack(); // Ensure Marker track is created. var objectsBeingDropped = DragAndDrop.objectReferences.OfType <Object>(); var candidateTime = TimelineHelpers.GetCandidateTime(Event.current.mousePosition); var perform = Event.current.type == EventType.DragPerform; var director = state.editSequence != null ? state.editSequence.director : null; DragAndDrop.visualMode = TimelineDragging.HandleClipPaneObjectDragAndDrop(objectsBeingDropped, timeline.markerTrack, perform, timeline, null, director, candidateTime, TimelineDragging.ResolveType); if (perform && DragAndDrop.visualMode == DragAndDropVisualMode.Copy) { DragAndDrop.AcceptDrag(); } }
private static AnimationClip CloneAnimationClipIfRequired(AnimationClip clip, Object owner) { AnimationClip result; if (clip == null) { result = null; } else { string assetPath = AssetDatabase.GetAssetPath(clip); string assetPath2 = AssetDatabase.GetAssetPath(owner); bool flag = assetPath == assetPath2; if (flag) { AnimationClip animationClip = Object.Instantiate <AnimationClip>(clip); animationClip.set_name(AnimationTrackRecorder.GetUniqueRecordedClipName(owner, clip.get_name())); animationClip.set_hideFlags(clip.get_hideFlags()); if ((clip.get_hideFlags() & 52) != 52 && assetPath2.Length > 0) { TimelineHelpers.SaveAnimClipIntoObject(animationClip, owner); } EditorUtility.SetDirty(owner); clip = animationClip; } result = clip; } return(result); }
internal bool Execute(WindowState state, Func <ITimelineItem, ITimelineItem, double> gapBetweenItems) { var selectedItems = SelectionManager.SelectedItems().ToItemsPerTrack().ToList(); if (selectedItems.Any()) { var requestedTime = CalculateDuplicateTime(selectedItems, gapBetweenItems); var duplicatedItems = TimelineHelpers.DuplicateItemsUsingCurrentEditMode(state, TimelineEditor.inspectedDirector, TimelineEditor.inspectedDirector, selectedItems, requestedTime, "Duplicate Items"); TimelineHelpers.FrameItems(state, duplicatedItems); SelectionManager.RemoveTimelineSelection(); foreach (var item in duplicatedItems) { SelectionManager.Add(item); } } var tracks = SelectionManager.SelectedTracks().ToArray(); if (tracks.Length > 0) { TrackAction.Invoke <DuplicateTracks>(state, tracks); } state.Refresh(); return(true); }
public static void SetSceneGameObject(PlayableDirector director, TrackAsset asset, GameObject go) { if (director == null || asset == null) { return; } asset = GetSceneReferenceTrack(asset); var bindings = asset.outputs; if (bindings.Count() == 0) { return; } var binding = bindings.First(); if (binding.outputTargetType == typeof(GameObject)) { BindingUtility.Bind(director, asset, go); } else { BindingUtility.Bind(director, asset, TimelineHelpers.AddRequiredComponent(go, asset)); } }
internal bool Execute(ActionContext context, Func <ITimelineItem, ITimelineItem, double> gapBetweenItems) { List <ITimelineItem> items = new List <ITimelineItem>(); items.AddRange(context.clips.Select(p => p.ToItem())); items.AddRange(context.markers.Select(p => p.ToItem())); List <ItemsPerTrack> selectedItems = items.ToItemsPerTrack().ToList(); if (selectedItems.Any()) { var requestedTime = CalculateDuplicateTime(selectedItems, gapBetweenItems); var duplicatedItems = TimelineHelpers.DuplicateItemsUsingCurrentEditMode(TimelineEditor.inspectedDirector, TimelineEditor.inspectedDirector, selectedItems, requestedTime, "Duplicate Items"); TimelineHelpers.FrameItems(duplicatedItems); SelectionManager.RemoveTimelineSelection(); foreach (var item in duplicatedItems) { SelectionManager.Add(item); } } var tracks = context.tracks.ToArray(); if (tracks.Length > 0) { tracks.Invoke <DuplicateTracks>(); } TimelineEditor.Refresh(RefreshReason.ContentsAddedOrRemoved); return(true); }
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 SelectLeftItem(bool shift = false) { if (ClipAreaActive()) { var items = SelectionManager.SelectedItems().ToList(); var clipOnly = FilterItems(ref items); var item = items.Last(); var prev = item.PreviousItem(clipOnly); if (prev != null) { if (shift) { if (SelectionManager.Contains(prev)) { SelectionManager.Remove(item); } SelectionManager.Add(prev); } else { SelectionManager.SelectOnly(prev); } TimelineHelpers.FrameItems(new[] { prev }); } else if (item != null && !shift && item.parentTrack != TimelineEditor.inspectedAsset.markerTrack) { SelectionManager.SelectOnly(item.parentTrack); } return(true); } return(false); }
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 bool SelectUpItem() { if (ClipAreaActive()) { var refItem = SelectionManager.SelectedItems().Last(); var prevTrack = refItem.parentTrack.PreviousTrack(); while (prevTrack != null) { var selectionItem = GetClosestItem(prevTrack, refItem); if (selectionItem == null) { prevTrack = prevTrack.PreviousTrack(); continue; } SelectionManager.SelectOnly(selectionItem); TimelineHelpers.FrameItems(new[] { selectionItem }); FrameTrackHeader(GetVisibleTracks().First(x => x.track == selectionItem.parentTrack)); break; } return(true); } return(false); }
/// <summary> /// Tries to select the first clip from a list of tracks /// </summary> /// <param name="tracks"></param> /// <returns>true if any expanded, false otherwise</returns> public static bool TrySelectFirstChild(IEnumerable <TrackAsset> tracks) { foreach (var track in tracks) { //Try to navigate in group tracks first if (track is GroupTrack) { if (track.GetChildTracks().Any()) { SelectionManager.SelectOnly(track.GetChildTracks().First()); return(true); } //Group tracks should not halt navigation continue; } //if track is locked or has no clips, do nothing if (track.lockedInHierarchy || !track.clips.Any()) { continue; } var firstClip = track.clips.First(); SelectionManager.SelectOnly(firstClip); TimelineHelpers.FrameItems(new ITimelineItem[] { firstClip.ToItem() }); return(true); } return(false); }