Exemplo n.º 1
0
        private Tween ShowNewMenu(GameObject targetMenu)
        {
            Sequence showSeq = DOTween.Sequence();

            float topY = menuElements[targetMenu].Select(canvasGroup => canvasGroup.transform.position.y).Max();

            if (targetMenu != optionsMenu)
            {
                var   titleRectTransform = title.GetComponent <RectTransform>();
                float targetPosY         = targetMenu == mainMenu ? mainMenuTitlePosition : creditsMenuTitlePosition;

                if (title.gameObject.activeSelf)
                {
                    showSeq.Append(titleRectTransform.DOAnchorPosY(targetPosY, titleMoveDuration));
                }
                else
                {
                    titleRectTransform.anchoredPosition = new Vector2(0, targetPosY);
                    topY = title.transform.position.y;
                    showSeq.AppendCallback(() => title.ActivateObject());
                    showSeq.Append(title.transform.DOPunchScale(Vector3.one * pulseMagnitude, fadeDuration, 0, 0));
                    showSeq.Join(title.DOFade(1, fadeDuration / 2));
                }
            }

            showSeq.AppendCallback(() => targetMenu.Activate());

            float baseLength = showSeq.Duration();

            foreach (CanvasGroup uiElement in menuElements[targetMenu])
            {
                float delay = (topY - uiElement.transform.position.y) * delayFactor;
                showSeq.Insert(baseLength + delay, uiElement.transform.DOPunchScale(Vector3.one * pulseMagnitude, fadeDuration, 0, 0));
                showSeq.Insert(baseLength + delay, uiElement.DOFade(1, fadeDuration / 2));
            }

            return(showSeq);
        }