Exemple #1
0
        public override void Metamorphose(LegoUIMeta uiMeta)
        {
            if (MetamorphoseStage == LegoMetamorphoseStage.Completed)
            {
                MetamorphoseStage = LegoMetamorphoseStage.Metamorphosing;
            }

            if (tButtonMeta == null)
            {
                tButtonMeta = uiMeta.NextTButton;
                RectMeta    = uiMeta.CurrentRect;
            }

            switch (tButtonStatus)
            {
            // 按钮自身变形
            case YuTButtonMetamorphoseStatus.Button:
                MetamorphoseRect(RectMeta);
                if (tButtonMeta.TransitionType == LegoTransition.ColorTint &&
                    tButtonMeta.ColorTintMeta != null)
                {
                    var colorTintMeta = tButtonMeta.ColorTintMeta;

                    colors = new ColorBlock
                    {
                        normalColor      = colorTintMeta.NormalLegoColor.ToColor(),
                        highlightedColor = colorTintMeta.HighlightedLegoColor.ToColor(),
                        pressedColor     = colorTintMeta.PressedLegoColor.ToColor(),
                        disabledColor    = colorTintMeta.DisabledLegoColor.ToColor(),
                        colorMultiplier  = colorTintMeta.ColorMultiplier,
                        fadeDuration     = colorTintMeta.FadeDuration
                    };
                }

                tButtonStatus = YuTButtonMetamorphoseStatus.ButtonImage;
                break;

            case YuTButtonMetamorphoseStatus.ButtonImage:
                // 按钮附带的Image变形
                BgImage.As <YuLegoImage>().Metamorphose(tButtonMeta.ButtonImageMeta);
                tButtonStatus = YuTButtonMetamorphoseStatus.IconImage;
                break;

            case YuTButtonMetamorphoseStatus.IconImage:
                IconImage.As <YuLegoImage>().Metamorphose(tButtonMeta.IconRectMeta,
                                                          tButtonMeta.IconImageMeta);
                tButtonStatus = YuTButtonMetamorphoseStatus.SonText;
                break;

            case YuTButtonMetamorphoseStatus.SonText:
                if (tButtonMeta.IsTextActive)
                {
                    SonText.gameObject.SetActive(true);
                    SonText.Metamorphose(tButtonMeta.TextRect, tButtonMeta.TextMeta);
                }
                else
                {
                    SonText.gameObject.SetActive(false);
                }

                tButtonMeta       = null;
                tButtonStatus     = YuTButtonMetamorphoseStatus.Button;
                MetamorphoseStage = LegoMetamorphoseStage.Completed;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }