private bool TryPreparePanel(UIPanel input, UITransition transition, float speed)
        {
            if (transitioning)
            {
                Debug.LogError("Wait for transition to end before setting new panel");
                return(false);
            }
            if (currentPanel != null)
            {
                currentPanel.onPanelTransitionOutStarted.Invoke((RectTransform)root_.transform);
            }

            clickBlocker.SetActive(true);
            passOverBlocker.SetActive(input.blockPassOver);

            inParent.SetSiblingIndex(transition.panelOnTop == UITransition.ParentSelection.inComingPanel ? 2 : 1);

            foreach (Transform child in inParent)
            {
                child.SetParent(outParent);
                RectTransform rt = (RectTransform)child;
                rt.anchorMin = Vector2.zero;
                rt.anchorMax = Vector2.one;
                rt.offsetMin = rt.offsetMax = Vector2.zero;
            }
            root.StartCoroutine(WaitForAnimationEnd(input, transition, speed));
            input.Initialise(this, (RectTransform)Instantiate(input.panelPrefab, inParent).transform);
            return(true);
        }
        private IEnumerator WaitForAnimationEnd(UIPanel panel, UITransition transition, float speed)
        {
            yield return(new WaitForSeconds(transition.inAnimation.length * speed));

            ClearOutParent();
            transitioning = false;
            animator.Play("Idle");
            currentPanel.onPanelTransitionedOut.Invoke(currentPanel.GetPanel());
            currentPanel = panel;
            clickBlocker.SetActive(false);
        }
Exemple #3
0
        public IEnumerator WaitForTransitionIn(RectTransform parent, UIManager manager, UITransition transition_, float speed)
        {
            yield return(new WaitForSeconds(transition_.inAnimation.length * speed));

            OnPanelTransitionedIn(manager, parent);
        }
Exemple #4
0
 /// <summary>
 /// Play set animation transition for this panel
 /// </summary>
 /// <param name="manager">UIManager handling Animation</param>
 public void PlayTransition(UIManager manager, UITransition transition_, float speed)
 {
     manager.animator.speed = 1f / speed;
     manager.animator.Play(transition_.inAnimation.name);
     manager.root.StartCoroutine(WaitForTransitionIn(instantiation, manager, transition_, speed));
 }