No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

TimelineNavigator.cs 4.9KB

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