/// <inheritdoc /> public async Task PopAsync(INavigationParameters parameters, AnimationOptions animationOptions) { if (m_IsBusy) { return; } if (m_Current == null) { throw new InvalidOperationException("Cannot pop if there is no screen current being displayed!"); } if (!m_Current.CanNavigate(parameters)) { return; } IScreenController previousScreen = null; if (m_NavigationStack.Count != 0) { previousScreen = m_NavigationStack.Pop(); } try { m_IsBusy = true; if (!animationOptions.enabled) { m_Current.OnScreenDestroyed(parameters); await m_Current.UpdateDisplayAsync(NavigationMode.Removed, false); if (previousScreen != null) { m_Current = previousScreen; m_Current.OnNavigatingBack(parameters); await m_Current.UpdateDisplayAsync(NavigationMode.Returning, false); m_Current.OnNavigatedBack(parameters); } else { m_Current = null; } } else { if (animationOptions.playSynchronously) { m_Current.OnScreenDestroyed(parameters); m_ParallelTasks.Clear(); m_ParallelTasks.Add(m_Current.UpdateDisplayAsync(NavigationMode.Removed)); if (previousScreen != null) { previousScreen.OnNavigatingBack(parameters); m_ParallelTasks.Add(previousScreen.UpdateDisplayAsync(NavigationMode.Returning)); } await Task.WhenAll(m_ParallelTasks); if (previousScreen != null) { m_Current = previousScreen; m_Current.OnNavigatedBack(parameters); } else { m_Current = null; } } else { m_Current.OnScreenDestroyed(parameters); await m_Current.UpdateDisplayAsync(NavigationMode.Removed); m_Current = previousScreen; m_Current.OnNavigatingBack(parameters); await m_Current.UpdateDisplayAsync(NavigationMode.Returning); m_Current.OnNavigatedBack(parameters); } m_EventManager.Invoke(new NavigationCompletedEvent(m_Current.id, m_NavigationStack)); } } catch (Exception e) { Debug.LogException(e); } finally { m_IsBusy = false; } }