/// <summary> /// Changes the current Timeline shown in the TimelineWindow to a new SequenceContext (if different and valid) /// </summary> /// <remarks> /// Should only ever accept SequenceContexts that are in the breadcrumbs. SetTimeline is the proper /// method to use to switch root Timelines. /// </remarks> /// <param name="context">A valid SequenceContext. <paramref name="context"/> should always be found in the breadcrumbs</param> /// <exception cref="System.ArgumentException"> The context is not valid</exception> /// <exception cref="System.InvalidOperationException"> The context is not a valid navigation destination.</exception> public void NavigateTo(SequenceContext context) { if (!context.IsValid()) { throw new ArgumentException( $"Argument {nameof(context)} is not valid. Check validity with SequenceContext.IsValid."); } //If the provided context is the current context if (windowState.editSequence.hostClip == context.clip && windowState.editSequence.director == context.director && windowState.editSequence.asset == context.director.playableAsset) { return; // Nothing to do } if (context.clip == null) { if (context.director != windowState.masterSequence.director) { throw new InvalidOperationException($"{nameof(context)} is not a valid destination in this context. " + $"To change the root context, use TimelineEditorWindow.SetTimeline instead."); } } var children = GetChildContexts().ToArray(); var breadcrumbs = CollectBreadcrumbContexts().ToArray(); if (!children.Contains(context) && !breadcrumbs.Contains(context)) { throw new InvalidOperationException( "The provided SequenceContext is not a valid destination. " + "Use GetChildContexts or GetBreadcrumbs to acquire valid destination contexts."); } if (children.Contains(context)) { windowState.SetCurrentSequence(context.director.playableAsset as TimelineAsset, context.director, context.clip); return; } var idx = Array.IndexOf(breadcrumbs, context); if (idx != -1) { windowState.PopSequencesUntilCount(idx + 1); } }
/// <summary> /// Navigates to a new SequenceContext. /// </summary> /// <param name="context">The context to navigate to.</param> /// <remarks> /// The SequenceContext provided must be a valid navigation destination. /// /// Valid navigation destinations: /// * The parent context returned by <see cref="GetParentContext"/>. /// * The root context returned by <see cref="GetRootContext"/>. /// * Any SequenceContext returned by <see cref="GetChildContexts"/>. /// * Any SequenceContext returned by <see cref="GetBreadcrumbs"/>. /// /// Note: This method cannot be used to change the root SequenceContext. To change the root SequenceContext, use <see cref="TimelineEditorWindow.SetTimeline"/>. /// /// </remarks> /// <exception cref="System.InvalidOperationException"> The Window associated to this instance has been destroyed.</exception> /// <exception cref="System.ArgumentException"> The context is not valid.</exception> /// <exception cref="System.InvalidOperationException"> The context is not a valid navigation destination.</exception> public void NavigateTo(SequenceContext context) { m_Impl.NavigateTo(context); }