public static LegoSliderMeta Create(YuLegoSlider slider)
        {
            var meta = new LegoSliderMeta();
            var rect = slider.RectTransform;

            meta.Transition = slider.transition.ToString()
                              .AsEnum <LegoTransition>();
            meta.ColorTintMeta = LegoColorTintMeta.Create(slider);

            var background = rect.Find("Background");

            meta.BackgroundImageRect = LegoRectTransformMeta.Create(background.RectTransform());
            meta.BackgroundImageMeta = LegoImageMeta.Create(background.GetComponent <YuLegoImage>());

            var fillArea = rect.Find("Fill Area");

            meta.FillAreaMeta = LegoRectTransformMeta.Create(fillArea.RectTransform());

            var fill = rect.Find("Fill Area/Fill");

            meta.FillImageRect = LegoRectTransformMeta.Create(fill.RectTransform());
            meta.FillImageMeta = LegoImageMeta.Create(fill.GetComponent <YuLegoImage>());

            var handleSlideArea = rect.Find("Handle Slide Area");

            meta.HandleSlideAreaRect = LegoRectTransformMeta.Create(handleSlideArea.RectTransform());

            var handle = rect.Find("Handle Slide Area/Handle");

            meta.HandleImageRect = LegoRectTransformMeta.Create(handle.RectTransform());
            meta.HandleImageMeta = LegoImageMeta.Create(handle.GetComponent <YuLegoImage>());

            meta.Direction      = slider.direction;
            meta.MinValue       = slider.minValue;
            meta.MaxValue       = slider.maxValue;
            meta.IsWholeNumbers = slider.wholeNumbers;

            return(meta);
        }
Exemple #2
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();
            }
        }
Exemple #3
0
        private void AddSliderMeta(Transform transform)
        {
            var sliderMeta = LegoSliderMeta.Create(transform.GetComponent <YuLegoSlider>());

            SliderMetas.Add(sliderMeta);
        }