public virtual void ShowContinue()
 {
     Status = UIAnimStatus.IsAnimationShow;
     InitRebornData();
     anim.Show(() =>
     {
         animContinue.Show(null, () => StartCoroutine(DORebornCountDown()), null);
     });
 }
 public void Hide(Action onHideDone = null)
 {
     Status = UIAnimStatus.IsAnimationHide;
     animResult.Hide();
     animContinue.Hide();
     anim.Hide(() =>
     {
         onHideDone?.Invoke();
         Status = UIAnimStatus.IsHide;
     });
 }
Пример #3
0
 private IEnumerator AutoHide(bool active = true)
 {
     while (elapsedTime > 0)
     {
         elapsedTime -= Time.deltaTime;
         yield return(null);
     }
     deActive.SetActive(!active);
     contentTransform.DOAnchorPos(contentStartPos.anchoredPosition, 0.125f)
     .OnComplete(() =>
     {
         Status = UIAnimStatus.IsHide;
         contentTransform.gameObject.SetActive(false);
     });
 }
 public virtual void ShowResult()
 {
     UIToast.ShowLoading("", 1);
     InitResultData();
     Status = UIAnimStatus.IsAnimationShow;
     if (anim.Status != UIAnimStatus.IsShow)
     {
         anim.Show(() => {
             animResult.Show(null, () => OnShowResult());
         });
     }
     else
     {
         animResult.Show(null, () => OnShowResult());
     }
 }
Пример #5
0
    private void Show(string mes = "", ToastType type = ToastType.Loading, float timeAutoHide = 3f, Sprite icon = null, string soundEffect = "")
    {
        toastType = type;
        if (!string.IsNullOrEmpty(mes) && mes.Length > maxLengthToSplit)
        {
            if (mes.Contains("...! "))
            {
                mes = mes.Replace("...! ", "...!\n");
            }
            else if (mes.Contains("... "))
            {
                mes = mes.Replace("... ", "...\n");
            }
            else if (mes.Contains(". "))
            {
                mes = mes.Replace(". ", ".\n");
            }
            else if (mes.Contains("!? "))
            {
                mes = mes.Replace("!? ", "!?\n");
            }
            else if (mes.Contains("! "))
            {
                mes = mes.Replace("! ", "!\n");
            }
        }

        elapsedTime = timeAutoHide;

        if (iconImage && icon == null)
        {
            switch (toastType)
            {
            case ToastType.Loading:
                if (iconLoading)
                {
                    iconImage.sprite = iconLoading;
                }
                break;

            case ToastType.Notification:
                if (iconNotification)
                {
                    iconImage.sprite = iconNotification;
                }
                if (!string.IsNullOrEmpty(soundNotification))
                {
                    soundEffect = soundNotification;
                }
                break;

            case ToastType.Error:
                if (iconError)
                {
                    iconImage.sprite = iconError;
                }
                if (!string.IsNullOrEmpty(soundError))
                {
                    soundEffect = soundError;
                }
                break;

            case ToastType.Unlock:
                if (iconUnlock)
                {
                    iconImage.sprite = iconUnlock;
                }
                if (!string.IsNullOrEmpty(soundUnlock))
                {
                    soundEffect = soundUnlock;
                }
                break;
            }
        }

        else
        {
            iconImage.sprite = icon;
        }

        if (!string.IsNullOrEmpty(soundEffect))
        {
            SoundManager.Play(soundEffect);
        }

        if (Status == UIAnimStatus.IsShow && message.text == mes.Trim())
        {
            Debug.LogWarning("Sample mes... return");
            return;
        }

        StopAllCoroutines();

        if (Status == UIAnimStatus.IsHide)
        {
            Status = UIAnimStatus.IsAnimationShow;

            contentTransform.gameObject.SetActive(true);
            contentTransform.DOKill(true);

            message.text = mes.Trim();
            message.gameObject.SetActive(false);
            horizontalLayoutGroup.enabled = false;

            contentTransform.anchoredPosition = contentStartPos.anchoredPosition;
            contentTransform.DOAnchorPos(startAnchoredPosition2D, 0.125f)
            .SetDelay(0.05f)
            .OnStart(() =>
            {
                contents.DOFade(!string.IsNullOrEmpty(mes) ? 1 : 0, 0);
                message.gameObject.SetActive(true);
                horizontalLayoutGroup.enabled = !string.IsNullOrEmpty(mes);
            })
            .OnComplete(() =>
            {
                message.gameObject.SetActive(true);
                horizontalLayoutGroup.enabled = !string.IsNullOrEmpty(mes);
                Status = UIAnimStatus.IsShow;
            });
        }
        else
        {
            contents.DOKill(true);
            contents.DOFade(0, 0.15f)
            .OnComplete(() =>
            {
                message.text = mes.Trim();
                message.gameObject.SetActive(false);
                horizontalLayoutGroup.enabled = false;
                contents.DOFade(!string.IsNullOrEmpty(mes) ? 1 : 0, 0.15f)
                .OnStart(() =>
                {
                    message.gameObject.SetActive(true);
                    horizontalLayoutGroup.enabled = !string.IsNullOrEmpty(mes);
                })
                .OnComplete(() =>
                {
                    message.gameObject.SetActive(true);
                    horizontalLayoutGroup.enabled = !string.IsNullOrEmpty(mes);
                });
            });
        }

        StartCoroutine(AutoHide());
        deActive.SetActive(toastType == ToastType.Loading);
    }