public override IEnumerator PlayReverse(NavScreen currentScreen, NavScreen previousScreen) { currentScreen.OnHiding(); if (previousScreen != null) { var currentScreenIndex = previousScreen.RectTransform.GetSiblingIndex(); previousScreen.RectTransform.SetSiblingIndex(currentScreenIndex); previousScreen.OnShowing(); } float progress = 0f; while (progress < 1) { progress += speed; progress = Mathf.Clamp01(progress); UpdateScreenPosition(currentScreen, 0f, 1f, progress); if (previousScreen != null) { UpdateScreenPosition(previousScreen, -0.3f, 0f, progress); } yield return(null); } currentScreen.OnHidden(); if (previousScreen != null) { previousScreen.OnShown(); } }
public override IEnumerator Play(NavScreen currentScreen, NavScreen nextScreen) { nextScreen.RectTransform.SetAsLastSibling(); nextScreen.OnShowing(); if (currentScreen != null) { currentScreen.OnHiding(); } float progress = 0f; while (progress < 1) { progress += speed; progress = Mathf.Clamp01(progress); UpdateScreenPosition(nextScreen, 1f, 0f, progress); if (currentScreen != null) { UpdateScreenPosition(currentScreen, 0f, -0.3f, progress); } yield return(null); } nextScreen.OnShown(); if (currentScreen != null) { currentScreen.OnHidden(); } }
public override IEnumerator PlayReverse(NavScreen currentScreen, NavScreen previousScreen) { currentScreen.OnHiding(); currentScreen.CanvasGroup.interactable = false; currentScreen.CanvasGroup.blocksRaycasts = false; if (previousScreen != null) { var currentScreenIndex = currentScreen.RectTransform.GetSiblingIndex(); previousScreen.RectTransform.SetSiblingIndex(currentScreenIndex); previousScreen.OnShowing(); previousScreen.CanvasGroup.alpha = 1f; } float progress = 0f; do { progress += speed; progress = Mathf.Clamp01(progress); UpdateScreenFade(currentScreen.CanvasGroup, 1f, 0f, progress); yield return(null); } while (progress < 1f); currentScreen.OnHidden(); if (previousScreen != null) { previousScreen.OnShown(); previousScreen.CanvasGroup.interactable = true; previousScreen.CanvasGroup.blocksRaycasts = true; } }
public override IEnumerator Play(NavScreen currentScreen, NavScreen nextScreen) { nextScreen.RectTransform.SetAsLastSibling(); nextScreen.OnShowing(); if (currentScreen != null) { currentScreen.OnHiding(); currentScreen.CanvasGroup.interactable = false; currentScreen.CanvasGroup.blocksRaycasts = false; } float progress = 0f; do { progress += speed; progress = Mathf.Clamp01(progress); UpdateScreenFade(nextScreen.CanvasGroup, 0f, 1f, progress); yield return(null); } while (progress < 1f); nextScreen.OnShown(); nextScreen.CanvasGroup.interactable = true; nextScreen.CanvasGroup.blocksRaycasts = true; if (currentScreen != null) { currentScreen.OnHidden(); currentScreen.CanvasGroup.alpha = 0f; } }
private void UpdateScreenPosition(NavScreen screen, float from, float to, float progress) { float easedProgress = Mathf.SmoothStep(from, to, progress); Vector2 newAnchorMin = new Vector2(easedProgress, 0f); Vector2 newAnchorMax = new Vector2(1f + easedProgress, 1f); screen.RectTransform.anchorMin = newAnchorMin; screen.RectTransform.anchorMax = newAnchorMax; }
protected void GoToScreenInternal(NavScreen screen) { for (int i = 0; i < screens.Length; i++) { screens[i].SetActive(false); } screens[(int)screen].SetActive(true); _currentScreen = screen; }
public static void GoToScreen(NavScreen screen) { Instance.GoToScreenInternal(screen); }