Example #1
0
 public void SetLabel(string text, bool isTween = true, Action callback = null)
 {
     Label.text        = text;
     CanvasGroup.alpha = 1;
     if (isTween)
     {
         CanvasGroup.DORestart();
         _tweener = CanvasGroup.DOFade(0, Time).SetEase(Ease.InExpo).OnComplete(() =>
         {
             if (callback != null)
             {
                 callback();
             }
         });
         _tweener.SetUpdate(true);
     }
     else
     {
         _timer.Start(Time, () =>
         {
             CanvasGroup.alpha = 0;
             if (callback != null)
             {
                 callback();
             }
         });
     }
 }
Example #2
0
 private void Awake()
 {
     m_Trans               = transform;
     m_EndY                = Screen.height / 2 - 100;
     m_StartY              = m_EndY - m_Trans.GetComponent <RectTransform>().sizeDelta.y *AppConst.TextTipsCount;
     m_Text                = m_Trans.Find("Text").GetComponent <Text>();
     m_Icon                = m_Trans.Find("Icon").GetComponent <Image>();
     m_CanvasGroup         = m_Trans.GetComponent <CanvasGroup>();
     m_Trans.localPosition = new Vector2(m_Trans.localPosition.x, m_StartY);
     m_Trans.DOLocalMoveY(m_EndY, AppConst.TextTipsYDuration).SetAutoKill(false).Pause().SetEase(Ease.OutCubic).OnComplete(() =>
     {
         m_CanvasGroup.DORestart();
     });
     m_CanvasGroup.DOFade(0, AppConst.TextTipsAlphaDuration).SetAutoKill(false).Pause().OnComplete(() =>
     {
         IsRun = false;
         m_Trans.localPosition = new Vector2(m_Trans.localPosition.x, m_StartY);
         m_Trans.gameObject.SetActive(false);
     });
 }