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

            if (progressbarMeta == null)
            {
                progressbarMeta = uiMeta.NextProgressbar;
                RectMeta        = uiMeta.CurrentRect;
            }

            switch (progressbarStatus)
            {
            case YuProgressbarMetamorphoseStatus.Progressbar:
                MetamorphoseRect(RectMeta);
                progressbarStatus = YuProgressbarMetamorphoseStatus.ImageBackground;
                break;

            case YuProgressbarMetamorphoseStatus.ImageBackground:
                ImageBackground.Metamorphose(progressbarMeta.BackgroundImageRect,
                                             progressbarMeta.BackgroundImageMeta);
                progressbarStatus = YuProgressbarMetamorphoseStatus.RectTransform_FillArea;
                break;

            case YuProgressbarMetamorphoseStatus.RectTransform_FillArea:
                YuLegoUtility.MetamorphoseRect(RectFillArea, progressbarMeta.FillAreaMeta);
                progressbarStatus = YuProgressbarMetamorphoseStatus.Image_Fill;
                break;

            case YuProgressbarMetamorphoseStatus.Image_Fill:
                ImageFill.Metamorphose(progressbarMeta.FillImageRect,
                                       progressbarMeta.FillImageMeta);

                progressbarMeta   = null;
                progressbarStatus = YuProgressbarMetamorphoseStatus.Progressbar;
                MetamorphoseStage = LegoMetamorphoseStage.Completed;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Пример #2
0
        public void Metamorphose(LegoRectTransformMeta rectMeta, LegoTextMeta textMeta)
        {
            originalSizeDelta = RectTransform.sizeDelta;
            YuLegoUtility.MetamorphoseRect(RectTransform, rectMeta);
            Text          = textMeta.Content;
            raycastTarget = textMeta.RaycastTarget;

            font = GetFont(textMeta.FontId.ToLower());
            //color = textMeta.Color.ToColor();
            fontStyle            = (FontStyle)(int)textMeta.FontStyle;
            fontSize             = textMeta.FontSize;
            lineSpacing          = textMeta.LineSpacing;
            supportRichText      = textMeta.RichText;
            resizeTextForBestFit = textMeta.BestFit;
            alignByGeometry      = textMeta.AlignByGeometry;

            alignment          = (TextAnchor)(int)textMeta.Alignment;
            verticalOverflow   = (VerticalWrapMode)(int)textMeta.VerticalOverflow;
            horizontalOverflow = (HorizontalWrapMode)(int)textMeta.HorizontalOverflow;
            UpdateAtStyleId();
        }
Пример #3
0
        public void Metamorphose(LegoUIMeta uiMeta)
        {
            if (MetamorphoseStage == LegoMetamorphoseStage.Completed)
            {
                MetamorphoseStage = LegoMetamorphoseStage.Metamorphosing;
            }

            if (scrollViewMeta == null)
            {
                scrollViewMeta = uiMeta.NextScrollView;
                RectMeta       = uiMeta.CurrentRect;
            }

            switch (metamorphoseStatus)
            {
            case MetamorphoseStatus.ScrollView:
                YuLegoUtility.MetamorphoseRect(RectTransform, RectMeta);
                ScrollViewImage.Metamorphose(scrollViewMeta.ScrollViewImageMeta);
                metamorphoseStatus = MetamorphoseStatus.ScrollRect;
                break;

            case MetamorphoseStatus.ScrollRect:
                YuLegoUtility.MetamorphoseRect(ScrollRectRect, scrollViewMeta.ScrollRectRectMeta);
                ScrollRectImage.Metamorphose(scrollViewMeta.ScrollRectImageMeta);
                metamorphoseStatus = MetamorphoseStatus.Content;
                break;

            case MetamorphoseStatus.Content:
                YuLegoUtility.MetamorphoseRect(Content, scrollViewMeta.ContentRectMeta);
                scrollViewMeta     = null;
                metamorphoseStatus = MetamorphoseStatus.ScrollView;
                MetamorphoseStage  = LegoMetamorphoseStage.Completed;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
        public void Metamorphose(LegoUIMeta uiMeta)
        {
            if (MetamorphoseStage == LegoMetamorphoseStage.Completed)
            {
                MetamorphoseStage = LegoMetamorphoseStage.Metamorphosing;
            }

            if (rockerMeta == null)
            {
                rockerMeta = uiMeta.NextRocker;
                RectMeta   = uiMeta.CurrentRect;
            }

            switch (metamorphose)
            {
            case MetamorphoseStatus.Rocker:
                YuLegoUtility.MetamorphoseRect(RectTransform, RectMeta);

                metamorphose = MetamorphoseStatus.BackgroundImage;
                break;

            case MetamorphoseStatus.BackgroundImage:
                BgImage.Metamorphose(rockerMeta.BgImageMeta);

                metamorphose = MetamorphoseStatus.RockerImage;
                break;

            case MetamorphoseStatus.RockerImage:
                RockerImage.Metamorphose(rockerMeta.RockerImageMeta);

                metamorphose      = MetamorphoseStatus.Rocker;
                MetamorphoseStage = LegoMetamorphoseStage.Completed;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Пример #5
0
        public override void Metamorphose(LegoUIMeta uiMeta)
        {
            if (MetamorphoseStage == LegoMetamorphoseStage.Completed)
            {
                MetamorphoseStage = LegoMetamorphoseStage.Metamorphosing;
            }

            if (toggleMeta == null)
            {
                toggleMeta = uiMeta.NextToggle;
                RectMeta   = uiMeta.CurrentRect;
            }

            switch (metamorphoseStatus)
            {
            case YuLegoToggleMetamorphoseStatus.Toggle:
                YuLegoUtility.MetamorphoseRect(RectTransform, uiMeta.CurrentRect);

                if (toggleMeta.Transition == LegoTransition.ColorTint)
                {
                    var colorTintMeta = toggleMeta.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
                    };
                }

                SoundEffectId      = toggleMeta.SoundId;
                metamorphoseStatus = YuLegoToggleMetamorphoseStatus.ImageBackground;
                break;

            case YuLegoToggleMetamorphoseStatus.ImageBackground:
                BackgroundImage.Metamorphose(toggleMeta.BackgroundRectMeta,
                                             toggleMeta.BackgroundImageMeta);
                metamorphoseStatus = YuLegoToggleMetamorphoseStatus.ImageCheck;
                break;

            case YuLegoToggleMetamorphoseStatus.ImageCheck:
                CheckmarkImage.Metamorphose(toggleMeta.CheckmarkRectMeta,
                                            toggleMeta.CheckMarkImageMeta);
                metamorphoseStatus = YuLegoToggleMetamorphoseStatus.SonText;
                break;

            case YuLegoToggleMetamorphoseStatus.SonText:
                metamorphoseStatus = YuLegoToggleMetamorphoseStatus.Toggle;
                Text.Metamorphose(toggleMeta.TextRect, toggleMeta.TextMeta);

                toggleMeta         = null;
                metamorphoseStatus = YuLegoToggleMetamorphoseStatus.Toggle;
                MetamorphoseStage  = LegoMetamorphoseStage.Completed;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Пример #6
0
        public override void Metamorphose(LegoUIMeta uiMeta)
        {
            if (MetamorphoseStage == LegoMetamorphoseStage.Completed)
            {
                MetamorphoseStage = LegoMetamorphoseStage.Metamorphosing;
            }

            if (sliderMeta == null)
            {
                sliderMeta = uiMeta.NextSlider;
                RectMeta   = uiMeta.CurrentRect;
            }

            switch (metamorphoseStatus)
            {
            case YuLegoSliderMetamorphoseStatus.Slider:
                YuLegoUtility.MetamorphoseRect(RectTransform, uiMeta.CurrentRect);

                direction    = sliderMeta.Direction;
                minValue     = sliderMeta.MinValue;
                maxValue     = sliderMeta.MaxValue == 0?1:sliderMeta.MaxValue;
                wholeNumbers = sliderMeta.IsWholeNumbers;

                if (sliderMeta.Transition == LegoTransition.ColorTint)
                {
                    var colorTintMeta = sliderMeta.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
                    };
                }

                metamorphoseStatus = YuLegoSliderMetamorphoseStatus.Image_Background;
                break;

            case YuLegoSliderMetamorphoseStatus.Image_Background:
                ImageBackground.Metamorphose(sliderMeta.BackgroundImageRect,
                                             sliderMeta.BackgroundImageMeta);
                metamorphoseStatus = YuLegoSliderMetamorphoseStatus.RectTransform_FillArea;
                break;

            case YuLegoSliderMetamorphoseStatus.RectTransform_FillArea:
                YuLegoUtility.MetamorphoseRect(RectFillArea, sliderMeta.FillAreaMeta);
                metamorphoseStatus = YuLegoSliderMetamorphoseStatus.Image_Fill;
                break;

            case YuLegoSliderMetamorphoseStatus.Image_Fill:
                ImageFill.Metamorphose(sliderMeta.FillImageRect, sliderMeta.FillImageMeta);
                metamorphoseStatus = YuLegoSliderMetamorphoseStatus.RectTransform_HandleSlideArea;
                break;

            case YuLegoSliderMetamorphoseStatus.RectTransform_HandleSlideArea:
                YuLegoUtility.MetamorphoseRect(HandleSlideArea, sliderMeta.HandleSlideAreaRect);
                metamorphoseStatus = YuLegoSliderMetamorphoseStatus.Image_Handle;
                break;

            case YuLegoSliderMetamorphoseStatus.Image_Handle:
                HandleImage.Metamorphose(sliderMeta.HandleImageRect, sliderMeta.HandleImageMeta);

                sliderMeta         = null;
                metamorphoseStatus = YuLegoSliderMetamorphoseStatus.Slider;
                MetamorphoseStage  = LegoMetamorphoseStage.Completed;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Пример #7
0
 protected void MetamorphoseRect(LegoRectTransformMeta rectMeta)
 {
     YuLegoUtility.MetamorphoseRect(RectTransform, rectMeta);
 }
Пример #8
0
        //private Sprite GetSprite(YuLegoDropdownOptionMeta optionMeta)
        //{
        //    var spriteId = optionMeta.SpriteId;

        //    if (spriteDict.ContainsKey(spriteId))
        //    {
        //        return spriteDict[spriteId].GetAsset();
        //    }

        //    var spRef = AssetModule.GetSprite(spriteId);
        //    spriteDict.Add(spriteId, spRef);
        //    return spRef.GetAsset();
        //}

        #endregion

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

            if (dropdownMeta == null)
            {
                dropdownMeta     = uiMeta.NextDropdown;
                dropdownRectMeta = uiMeta.CurrentRect;
            }

            switch (metamorphoseStatus)
            {
            case MetamorphoseStatus.Dropdown:
                MetamorphoseRect(dropdownRectMeta);

                // 输入框自身附带Image控件变形
                SelfImage.Metamorphose(dropdownMeta.DropdownImageMeta);

                if (dropdownMeta.Transition == LegoTransition.ColorTint)
                {
                    var colorTintMeta = dropdownMeta.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
                    };
                }

                // 选项
                if (dropdownMeta.OptionMetas != null && dropdownMeta.OptionMetas.Count > 0)
                {
                    options.Clear();

                    foreach (var optionMeta in dropdownMeta.OptionMetas)
                    {
                        var optionData = new OptionData();
                        optionData.text = optionMeta.Text;
                        // todo 下拉框菜单精灵

                        //optionData.image = SpriteRouter.GetSprite(optionMeta.SpriteId);
                        options.Add(optionData);
                    }
                }

                metamorphoseStatus = MetamorphoseStatus.Label;
                break;

            case MetamorphoseStatus.Label:
                Label.Metamorphose(dropdownMeta.LabelRectMeta, dropdownMeta.LabelTextMeta);
                metamorphoseStatus = MetamorphoseStatus.Arrow;
                break;

            case MetamorphoseStatus.Arrow:
                Arrow.Metamorphose(dropdownMeta.ArrowRectMeta, dropdownMeta.ArrowImageMeta);
                metamorphoseStatus = MetamorphoseStatus.Template;
                break;

            case MetamorphoseStatus.Template:
                TemplateImage.Metamorphose(dropdownMeta.TemplateRectMeta, dropdownMeta.TemplateImageMeta);
                metamorphoseStatus = MetamorphoseStatus.Viewport;
                break;

            case MetamorphoseStatus.Viewport:
                ViewportImage.Metamorphose(dropdownMeta.ViewPortRectMeta, dropdownMeta.ViewPortImageMeta);
                metamorphoseStatus = MetamorphoseStatus.Content;
                break;

            case MetamorphoseStatus.Content:
                YuLegoUtility.MetamorphoseRect(Content, dropdownMeta.ContentRectMeta);
                metamorphoseStatus = MetamorphoseStatus.Item;
                break;

            case MetamorphoseStatus.Item:
                if (dropdownMeta.ItemTransition == LegoTransition.ColorTint)
                {
                    var colorTintMeta = dropdownMeta.ItemRootColorTintMeta;

                    Item.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
                    };
                }

                YuLegoUtility.MetamorphoseRect(Item.RectTransform, dropdownMeta.ItemRootRectMeta);
                metamorphoseStatus = MetamorphoseStatus.ItemBackground;
                break;

            case MetamorphoseStatus.ItemBackground:
                ItemBackground.Metamorphose(dropdownMeta.ItemBackgroundRectMeta,
                                            dropdownMeta.ItemBackgroundImageMeta);
                metamorphoseStatus = MetamorphoseStatus.ItemCheckmark;
                break;

            case MetamorphoseStatus.ItemCheckmark:
                ItemCheckmark.Metamorphose(dropdownMeta.ItemCheckmarkRectMeta,
                                           dropdownMeta.ItemCheckmarkImageMeta);
                metamorphoseStatus = MetamorphoseStatus.ItemLabel;
                break;

            case MetamorphoseStatus.ItemLabel:
                ItemLabel.Metamorphose(dropdownMeta.ItemLabelRectMeta,
                                       dropdownMeta.ItemLabelTextMeta);
                metamorphoseStatus = MetamorphoseStatus.Scrollbar;
                break;

            case MetamorphoseStatus.Scrollbar:
                ScrollbarImage.Metamorphose(dropdownMeta.ScrollbarRectMeta,
                                            dropdownMeta.ScrollbarImageMeta);
                metamorphoseStatus = MetamorphoseStatus.SlidingArea;
                break;

            case MetamorphoseStatus.SlidingArea:
                YuLegoUtility.MetamorphoseRect(SlidingArea, dropdownMeta.SlidingAreaRectMeta);
                metamorphoseStatus = MetamorphoseStatus.Handle;
                break;

            case MetamorphoseStatus.Handle:
                HandleImage.Metamorphose(dropdownMeta.ScrollbarHandleRectMeta,
                                         dropdownMeta.ScrollbarHandleImageMeta);

                dropdownMeta       = null;
                dropdownRectMeta   = null;
                metamorphoseStatus = MetamorphoseStatus.Dropdown;
                MetamorphoseStage  = LegoMetamorphoseStage.Completed;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }