Ejemplo n.º 1
0
 public override void OnEnable()
 {
     base.OnEnable();
     Trans.localScale = Vector3.one * 0.1f;
     if (tween != null)
     {
         tween.Kill();
     }
     tween = Trans.DOScale(Vector3.one, Duration).SetEase(Ease);
 }
Ejemplo n.º 2
0
 public virtual void OnClose()
 {
     if (IsScaleWhenCloseTime)
     {
         Trans.localScale = MinScale;
     }
     //flicker effect
     if (DispearType == PerformDispearType.Flicker && CloseTime > 0.0f)
     {
         flickerEffect.StartEffect(0.0f, CloseTime);
     }
     else if (DispearType == PerformDispearType.Scale)
     {
         if (ScaleTweener != null)
         {
             ScaleTweener.Kill();
         }
         ScaleTweener = Trans.DOScale(MinScale, CloseTime);
     }
     StopParticle();
 }
Ejemplo n.º 3
0
        protected void OnShowScaleEffect(float mainShowTime)
        {
            if (scaleTween != null)
            {
                scaleTween.Kill();
            }
            Vector3 minScale = sourceLocalScale * 0.001f;

            if (IsShow && TweenMove.IsReset)
            {
                Trans.localScale = minScale;
            }
            if (mainShowTime >= 0)
            {
                scaleTween = Trans.DOScale(
                    IsShow ? sourceLocalScale : minScale,
                    mainShowTime)
                             .SetEase(IsShow ? TweenScale.InEase : TweenScale.OutEase)
                             .SetDelay(Delay);
            }
        }
Ejemplo n.º 4
0
        public override void Show(bool b = true, float?fadeTime = null, float delay = 0, bool useGroup = true, bool force = false)
        {
            if (IsShow == b && !force)
            {
                return;
            }
            float tempFade = 0.0f;

            if (fadeTime != null)
            {
                tempFade = fadeTime.Value;
            }
            else
            {
                tempFade = IsSameTime?Duration : (b ? InTime : OutTime);
            }
            IsShow = b;

            if (scaleTween != null)
            {
                scaleTween.Kill();
            }
            if (IsScale)
            {
                scaleTween = Trans.DOScale(IsShow ? 1.0f : 0.001f, tempFade).SetEase(IsShow ? TweenScale.InEase : TweenScale.OutEase);
            }
            else
            {
                scaleTween = Trans.DOScale(IsShow ? 1.0f : 0.001f, 0).SetEase(TweenScale.InEase);
            }
            if (IsShow)
            {
                OnOpen(this, useGroup);
                scaleTween.OnStart(OnFadeIn);
                scaleTween.SetDelay(delay);
            }
            else
            {
                OnClose();
                scaleTween.OnComplete(OnFadeOut);
                scaleTween.SetDelay(delay);
            }

            if (IsShow)
            {
                SetDirty();
                //UI互斥,相同UI组只能有一个UI被打开
                if (useGroup && Group > 0)
                {
                    for (int i = 0; i < SubViews.Count; ++i)
                    {
                        if (SubViews[i] != this && SubViews[i].Group == Group && SubViews[i].ViewLevel == ViewLevel)
                        {
                            SubViews[i].Show(false, null, 0, false);
                        }
                    }
                }
            }
            else
            {
                //关闭界面的时候自动刷新父级界面
                if (ParentView.IsShow && !ParentView.IsRootView)
                {
                    ParentView.SetDirty();
                }
                //关闭子界面
                foreach (var item in SubViews)
                {
                    item.Show(false);
                }
            }

            OnShow();
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 显示或者关闭界面
        /// </summary>
        /// <param name="b"></param>
        public override void Show(bool b = true, float?fadeTime = null, float delay = 0, bool useGroup = true, bool force = false)
        {
            if (IsShow == b && !force)
            {
                return;
            }
            if (Delay == 0)
            {
                Delay = delay;
            }

            base.Show(b, fadeTime, delay, useGroup, force);
            float mainShowTime = 0.0f;

            IsShow = b;

            //设置时长
            if (fadeTime != null)
            {
                mainShowTime = fadeTime.Value;
            }
            else
            {
                mainShowTime = IsSameTime? Duration : (b ? InTime : OutTime);
            }

            //停止之前的tween
            if (alphaTween != null)
            {
                alphaTween.Kill();
            }
            if (scaleTween != null)
            {
                scaleTween.Kill();
            }
            if (moveTween != null)
            {
                moveTween.Kill();
            }

            //Alpha效果
            alphaTween = DOTween.To(
                () => canvasGroup.alpha,
                x => canvasGroup.alpha = x,
                b ? 1.0f : 0.0f,
                mainShowTime);
            if (IsShow)
            {
                OnOpen(this, useGroup);
                alphaTween.OnStart(OnFadeIn);
                alphaTween.SetDelay(Delay);
            }
            else
            {
                OnClose();
                alphaTween.OnComplete(OnFadeOut);
                alphaTween.SetDelay(Delay);
            }
            //缩放效果
            if (IsScale)
            {
                Vector3 minScale = sourceLocalScale * 0.001f;
                if (IsShow)
                {
                    Trans.localScale = minScale;
                }
                scaleTween = Trans.DOScale(IsShow ? sourceLocalScale : minScale,
                                           mainShowTime)
                             .SetEase(IsShow ? TweenScale.InEase : TweenScale.OutEase)
                             .SetDelay(Delay);
            }
            //位移效果
            if (IsMove)
            {
                if (IsShow)
                {
                    RectTrans.anchoredPosition = TweenMove.StartPos;
                }
                moveTween = DOTween.To(
                    () => RectTrans.anchoredPosition,
                    (x) => RectTrans.anchoredPosition = x, b ? sourceAnchoredPosition : TweenMove.StartPos,
                    mainShowTime)
                            .SetEase(IsShow ? TweenMove.InEase : TweenMove.OutEase)
                            .SetDelay(Delay);
            }

            //屏蔽/取消屏蔽 UI点击
            if (canvasGroup != null)
            {
                canvasGroup.blocksRaycasts = IsShow;
            }
            //触发控件的ViewShow事件
            foreach (var item in presenters)
            {
                item.OnViewShow(b);
            }

            //执行UI互斥
            if (IsShow)
            {
                SetDirty();
                //UI互斥,相同UI组只能有一个UI被打开
                if (useGroup && Group > 0)
                {
                    for (int i = 0; i < SubViews.Count; ++i)
                    {
                        if (SubViews[i] != this && SubViews[i].Group == Group && SubViews[i].ViewLevel == ViewLevel)
                        {
                            SubViews[i].Show(false, null, 0, false);
                        }
                    }
                }
            }
            else
            {
                if (ParentView != null)
                {
                    //关闭界面的时候自动刷新父级界面
                    if (ParentView.IsShow && !ParentView.IsRootView)
                    {
                        ParentView.SetDirty();
                    }
                }
                foreach (var item in SubViews)
                {
                    item.Show(false);
                }
            }
            //刷新panel
            foreach (var item in PGList)
            {
                item.RefreshShow();
            }

            OnShow();
            Delay = 0;//重置Delay
        }