A game about forced loneliness, made by TACStudios
at master 97 lines 5.1 kB view raw
1using System.Collections.Generic; 2 3namespace UnityEditor.Timeline 4{ 5 /// <summary> 6 /// Interface to navigate through Timelines and SubTimelines for the Timeline window. 7 /// </summary> 8 /// <remarks> 9 /// TimelineNavigator gives you access to the Timeline window breadcrumbs functionality. Use it to programmatically 10 /// dig into SubTimelines, navigate to parent Timelines or navigate Timeline Window breadcrumbs. 11 /// </remarks> 12 public sealed class TimelineNavigator 13 { 14 TimelineWindow.TimelineNavigatorImpl m_Impl; 15 internal TimelineNavigator(IWindowStateProvider windowState) 16 { 17 m_Impl = new TimelineWindow.TimelineNavigatorImpl(windowState); 18 } 19 20 /// <summary> 21 /// Gets the SequenceContext associated with the Timeline currently shown in the Timeline window. 22 /// </summary> 23 /// <returns>The SequenceContext associated with the Timeline currently shown in the Timeline window.</returns> 24 /// <remarks>Equivalent to <c>TimelineNavigator.GetBreadCrumbs().Last()</c></remarks> 25 /// <exception cref="System.InvalidOperationException"> The Window associated to this instance has been destroyed.</exception> 26 public SequenceContext GetCurrentContext() 27 { 28 return m_Impl.GetCurrentContext(); 29 } 30 31 /// <summary> 32 /// Gets the parent SequenceContext for the Timeline currently shown in the Timeline window. 33 /// </summary> 34 /// <returns>The parent SequenceContext for the Timeline currently shown in the Timeline window if there is one; an invalid SequenceContext otherwise. <seealso cref="SequenceContext.Invalid"/></returns> 35 /// <exception cref="System.InvalidOperationException"> The Window associated to this instance has been destroyed.</exception> 36 public SequenceContext GetParentContext() 37 { 38 return m_Impl.GetParentContext(); 39 } 40 41 /// <summary> 42 /// Gets the first SequenceContext in the breadcrumbs. 43 /// </summary> 44 /// <returns>The first SequenceContext in the breadcrumbs.</returns> 45 /// <remarks>Equivalent to <c>TimelineNavigator.GetBreadCrumbs().First()</c></remarks> 46 /// <exception cref="System.InvalidOperationException"> The Window associated to this instance has been destroyed.</exception> 47 public SequenceContext GetRootContext() 48 { 49 return m_Impl.GetRootContext(); 50 } 51 52 /// <summary> 53 /// Gets the collection of child contexts that can be navigated to from the current context. 54 /// </summary> 55 /// <returns>The collection of child contexts that can be navigated to from the current context.</returns> 56 /// <exception cref="System.InvalidOperationException"> The Window associated to this instance has been destroyed.</exception> 57 public IEnumerable<SequenceContext> GetChildContexts() 58 { 59 return m_Impl.GetChildContexts(); 60 } 61 62 /// <summary> 63 /// Gets the collection of SequenceContexts associated with the breadcrumbs shown in the TimelineEditorWindow. 64 /// </summary> 65 /// <remarks>This operation can be expensive. Consider caching the results instead of calling the method multiple times.</remarks> 66 /// <returns>The collection of SequenceContexts associated with the breadcrumbs shown in the TimelineEditorWindow, from the root context to the current context.</returns> 67 /// <exception cref="System.InvalidOperationException"> The Window associated to this instance has been destroyed.</exception> 68 public IEnumerable<SequenceContext> GetBreadcrumbs() 69 { 70 return m_Impl.GetBreadcrumbs(); 71 } 72 73 /// <summary> 74 /// Navigates to a new SequenceContext. 75 /// </summary> 76 /// <param name="context">The context to navigate to.</param> 77 /// <remarks> 78 /// The SequenceContext provided must be a valid navigation destination. 79 /// 80 /// Valid navigation destinations: 81 /// * The parent context returned by <see cref="GetParentContext"/>. 82 /// * The root context returned by <see cref="GetRootContext"/>. 83 /// * Any SequenceContext returned by <see cref="GetChildContexts"/>. 84 /// * Any SequenceContext returned by <see cref="GetBreadcrumbs"/>. 85 /// 86 /// Note: This method cannot be used to change the root SequenceContext. To change the root SequenceContext, use <see cref="TimelineEditorWindow.SetTimeline"/>. 87 /// 88 /// </remarks> 89 /// <exception cref="System.InvalidOperationException"> The Window associated to this instance has been destroyed.</exception> 90 /// <exception cref="System.ArgumentException"> The context is not valid.</exception> 91 /// <exception cref="System.InvalidOperationException"> The context is not a valid navigation destination.</exception> 92 public void NavigateTo(SequenceContext context) 93 { 94 m_Impl.NavigateTo(context); 95 } 96 } 97}