コード例 #1
0
    private IEnumerator AnimateFromCornerWithoutScale_HIDE()
    {
        if (animationHideDuration <= 0)
        {
            yield break;
        }

        Vector3 startPos       = initialWorldPosition;
        Vector3 targetPosition = AiryUIAnimationPositions.GetStartPositionFromCorner(initialWorldPosition, rectTransform, animationToCornerType, animationFromCornerStartFromType);

        rectTransform.position = startPos;

        if (withDelay)
        {
            yield return(new WaitForSeconds(hideDelay));
        }

        float startTime = Time.time;

        while (Time.time <= startTime + animationHideDuration)
        {
            float t = (Time.time - startTime) / animationHideDuration;
            rectTransform.position = Vector3.Lerp(startPos, targetPosition, t);

            yield return(null);
        }

        rectTransform.position = targetPosition;

        if (OnHideComplete != null)
        {
            OnHideComplete.Invoke();
        }
    }
コード例 #2
0
    private IEnumerator AnimateToCornerWithScale_HIDE()
    {
        if (animationHideDuration <= 0)
            yield break;

        Graphic[] images;

        if (fadeChildren)
            images = GetComponentsInChildren<Graphic>();
        else
            images = GetComponents<Graphic>();

        Color[] startColors = new Color[images.Length];
        Color[] endColors = new Color[images.Length];

        for (int i = 0; i < images.Length; i++)
        {
            startColors[i] = initialColorsOfChildren[i];

            endColors[i] = images[i].color;
            endColors[i].a = 0;
        }


        Vector3 startPos = initialWorldPosition;
        Vector3 targetPosition = AiryUIAnimationPositions.GetStartPositionFromCorner(initialWorldPosition, rectTransform, animationToCornerType, animationFromCornerStartFromType);
        rectTransform.position = startPos;

        if (withDelay)
            yield return (new WaitForSeconds(hideDelay));

        float startTime = Time.time;

        while (Time.time <= startTime + animationHideDuration)
        {
            float t = (Time.time - startTime) / animationHideDuration;
            rectTransform.position = Vector3.Lerp(startPos, targetPosition, t);
            rectTransform.localScale = Vector3.Lerp(Vector3.one, Vector3.zero, t);

            for (int i = 0; i < images.Length; i++)
            {
                images[i].color = Color.Lerp(startColors[i], endColors[i], t);
            }

            yield return (null);
        }

        rectTransform.position = targetPosition;
        rectTransform.localScale = Vector3.zero;

        for (int i = 0; i < images.Length; i++)
        {
            images[i].color = endColors[i];
        }

        if (OnHideComplete != null)
            OnHideComplete.Invoke();
    }
コード例 #3
0
    private IEnumerator AnimateFromCornerWithoutScale_SHOW()
    {
        if (animationShowDuration <= 0)
        {
            yield break;
        }

        ResetPosition();
        ResetScale(ResetOptions.Zero);
        ResetColor(ResetOptions.Zero);

        #region Initialization Part


        Vector3 startPos       = AiryUIAnimationPositions.GetStartPositionFromCorner(initialWorldPosition, rectTransform, animationFromCornerType, AnimationFromCornerStartFromType.Screen);
        Vector3 targetPosition = initialWorldPosition;

        rectTransform.position = startPos;

        #endregion

        if (withDelay)
        {
            yield return(new WaitForSeconds(showDelay));
        }

        ResetPosition();
        ResetScale(ResetOptions.One);
        ResetColor(ResetOptions.One);

        // Starting animating.
        float startTime = Time.time;

        rectTransform.position = startPos;

        while (Time.time <= startTime + animationShowDuration)
        {
            float t = (Time.time - startTime) / animationShowDuration;

            // Here we Lerp the position and the scale as well.
            rectTransform.position = Vector3.Lerp(startPos, targetPosition, t);

            yield return(null);
        }

        // Here we set the values to their end so we avoid the missing final step.
        rectTransform.position = targetPosition;

        if (OnShowComplete != null)
        {
            OnShowComplete.Invoke();
        }
    }
コード例 #4
0
    private IEnumerator AnimateFromCornerWithScale_SHOW()
    {
        if (animationShowDuration <= 0)
        {
            yield break;
        }

        ResetPosition();
        ResetScale(ResetOptions.Zero);
        ResetColor(ResetOptions.Zero);

        #region Initialization Part

        Graphic[] imagesInMenu = GetComponentsInChildren <Graphic>();

        // Here we get start color to a color with alpha = 0, and the end color to a color with alpha = 1.
        Color[] startColors = new Color[imagesInMenu.Length];
        Color[] endColors   = new Color[imagesInMenu.Length];

        for (int i = 0; i < graphics.Length; i++)
        {
            startColors[i]   = graphics[i].color;
            startColors[i].a = 0;

            endColors[i] = initialColorsOfChildren[i];
        }

        Vector3 startPos = AiryUIAnimationPositions.GetStartPositionFromCorner(initialWorldPosition, rectTransform, animationFromCornerType, AnimationFromCornerStartFromType.Screen);

        Vector3 targetPosition = initialWorldPosition;
        rectTransform.position = startPos;

        #endregion

        if (withDelay)
        {
            yield return(new WaitForSeconds(showDelay));
        }

        // Starting animating.
        rectTransform.position = startPos;

        float startTime = Time.time;

        while (Time.time <= startTime + animationShowDuration)
        {
            float t = (Time.time - startTime) / animationShowDuration;

            // Here we Lerp the position and the scale as well.
            rectTransform.position   = Vector3.Lerp(startPos, targetPosition, t);
            rectTransform.localScale = Vector3.Lerp(Vector3.zero, Vector3.one, t);

            // Here we lerp the color from totally transparent to totally visible.
            for (int i = 0; i < imagesInMenu.Length; i++)
            {
                imagesInMenu[i].color = Color.Lerp(startColors[i], endColors[i], t);
            }

            yield return(null);
        }

        // Here we set the values to their end so we avoid the missing final step.
        rectTransform.position   = targetPosition;
        rectTransform.localScale = Vector3.one;

        for (int i = 0; i < imagesInMenu.Length; i++)
        {
            imagesInMenu[i].color = endColors[i];
        }

        if (OnShowComplete != null)
        {
            OnShowComplete.Invoke();
        }
    }