public static LegoInputFieldMeta Create(YuLegoInputField inputField)
        {
            var rect = inputField.RectTransform;
            var meta = new LegoInputFieldMeta
            {
                Transition    = inputField.transition.ToString().AsEnum <LegoTransition>(),
                ColorTintMeta = LegoColorTintMeta.Create(inputField),
                InputSoundId  = inputField.SoundEffectId
            };

            var image = inputField.GetComponent <YuLegoImage>();

            meta.RootImageMeta = LegoImageMeta.Create(image);

            var textPlaceHolder = rect.Find("Placeholder");

            meta.PlaceHolderTextRectMeta = LegoRectTransformMeta
                                           .Create(textPlaceHolder.GetComponent <RectTransform>());
            meta.PlaceHolderTextMeta = LegoTextMeta.Create(textPlaceHolder.GetComponent <YuLegoText>());

            var textContent = rect.Find("Text");

            meta.ContentTextRectMeta = LegoRectTransformMeta.Create(textContent.RectTransform());
            meta.ContentTextMeta     = LegoTextMeta.Create(textContent.GetComponent <YuLegoText>());

            return(meta);
        }
        public static LegoToggleMeta Create(YuLegoToggle toggle)
        {
            var rect = toggle.RectTransform;
            var meta = new LegoToggleMeta
            {
                Interactable  = toggle.interactable,
                Transition    = toggle.transition.ToString().AsEnum <LegoTransition>(),
                ColorTintMeta = LegoColorTintMeta.Create(toggle),
                SoundId       = toggle.SoundEffectId
            };

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

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

            var checkmark = rect.Find("Background/Checkmark");

            meta.CheckmarkRectMeta  = LegoRectTransformMeta.Create(checkmark.RectTransform());
            meta.CheckMarkImageMeta = LegoImageMeta.Create(checkmark.GetComponent <YuLegoImage>());

            var text = rect.Find("Text");

            meta.TextRect = LegoRectTransformMeta.Create(text.RectTransform());
            meta.TextMeta = LegoTextMeta.Create(text.GetComponent <YuLegoText>());

            return(meta);
        }
        public static LegoProgressbarMeta Create(YuLegoProgressbar legoProgressbar)
        {
            var meta = new LegoProgressbarMeta();
            var rect = legoProgressbar.RectTransform;

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

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

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

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

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

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

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

            return(meta);
        }
        public static LegoColorTintMeta Create(Selectable selectable)
        {
            var meta       = new LegoColorTintMeta();
            var colorBlock = selectable.colors;

            meta.NormalLegoColor      = LegoColorMeta.Create(colorBlock.normalColor);
            meta.HighlightedLegoColor = LegoColorMeta.Create(colorBlock.highlightedColor);
            meta.PressedLegoColor     = LegoColorMeta.Create(colorBlock.pressedColor);
            meta.DisabledLegoColor    = LegoColorMeta.Create(colorBlock.disabledColor);
            meta.ColorMultiplier      = colorBlock.colorMultiplier;
            meta.FadeDuration         = colorBlock.fadeDuration;

            return(meta);
        }
Beispiel #5
0
        public static LegoTButtonMeta Create(YuLegoTButton button)
        {
            var meta = new LegoTButtonMeta
            {
                Interactable   = button.interactable,
                TransitionType = button.transition.ToString().AsEnum <LegoTransition>()
            };

            switch (meta.TransitionType)
            {
            case LegoTransition.None:
                break;

            case LegoTransition.ColorTint:
                meta.ColorTintMeta = LegoColorTintMeta.Create(button);
                break;

            case LegoTransition.SpriteSwap:
                meta.SpriteSwapMeta = LegoSpriteSwapMeta.create(button);
                break;

            case LegoTransition.Animation:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            // 按钮上的图片
            meta.ButtonImageMeta = LegoImageMeta.Create(button.BgImage.As <YuLegoImage>());

            // 子文本
            meta.IsTextActive = button.SonText.gameObject.activeSelf;
            meta.TextRect     = LegoRectTransformMeta.Create(button.SonText.rectTransform);
            meta.TextMeta     = LegoTextMeta.Create(button.SonText);

            // 图标图片
            meta.IconRectMeta  = LegoRectTransformMeta.Create(button.IconImage.RectTransform);
            meta.IconImageMeta = LegoImageMeta.Create(button.IconImage.As <YuLegoImage>());

            return(meta);
        }
        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);
        }
        public static LegoPlaneToggleMeta Create(YuLegoPlaneToggle toggle)
        {
            var rect = toggle.RectTransform;
            var meta = new LegoPlaneToggleMeta
            {
                Interactable   = toggle.interactable,
                TransitionType = toggle.transition.ToString().AsEnum <LegoTransition>(),
                ColorTintMeta  = LegoColorTintMeta.Create(toggle),
                SoundId        = toggle.SoundEffectId
            };

            // 开关自身图片元数据
            meta.ToggleImageMeta = LegoImageMeta.Create(toggle.ToggleImage.As <YuLegoImage>());

            var imageFrontPoint = rect.Find(IMAGE_FRONT_POINT);

            meta.ImageFrontPointRectMeta = LegoRectTransformMeta
                                           .Create(imageFrontPoint.RectTransform());
            meta.ImageFrontPointImageMeta = LegoImageMeta
                                            .Create(imageFrontPoint.GetComponent <YuLegoImage>());

            return(meta);
        }
Beispiel #8
0
        public static LegoDropdownMeta Create(YuLegoDropdown dropdown)
        {
            var meta = new LegoDropdownMeta
            {
                Transition    = dropdown.transition.ToString().AsEnum <LegoTransition>(),
                ColorTintMeta = LegoColorTintMeta.Create(dropdown),
                OptionMetas   = new List <YuLegoDropdownOptionMeta>(),
            };

            var dropdownImage = dropdown.RectTransform.GetComponent <YuLegoImage>();

            meta.DropdownImageMeta = LegoImageMeta.Create(dropdownImage);

            foreach (var optionData in dropdown.options)
            {
                var optionMeta = YuLegoDropdownOptionMeta.Create(optionData);
                meta.OptionMetas.Add(optionMeta);
            }

            var label = dropdown.RectTransform.Find("Label")
                        .GetComponent <YuLegoText>();

            meta.LabelRectMeta = LegoRectTransformMeta.Create(label.rectTransform);
            meta.LabelTextMeta = LegoTextMeta.Create(label);

            var arrow = dropdown.RectTransform.Find("Arrow")
                        .GetComponent <YuLegoImage>();

            meta.ArrowRectMeta  = LegoRectTransformMeta.Create(arrow.RectTransform);
            meta.ArrowImageMeta = LegoImageMeta.Create(arrow);

            var template = dropdown.RectTransform.Find("Template")
                           .GetComponent <RectTransform>();

            meta.TemplateRectMeta  = LegoRectTransformMeta.Create(template);
            meta.TemplateImageMeta = LegoImageMeta.Create(template.GetComponent <YuLegoImage>());

            var viewport = template.Find("Viewport").GetComponent <RectTransform>();

            meta.ViewPortRectMeta  = LegoRectTransformMeta.Create(viewport);
            meta.ViewPortImageMeta = LegoImageMeta.Create(viewport.GetComponent <YuLegoImage>());

            var content = viewport.Find("Content").GetComponent <RectTransform>();

            meta.ContentRectMeta = LegoRectTransformMeta.Create(content);

            var item = content.Find("Item").GetComponent <RectTransform>();

            meta.ItemRootRectMeta = LegoRectTransformMeta.Create(item);
            var itemRootToggle = item.GetComponent <YuLegoToggle>();

            meta.ItemTransition          = itemRootToggle.transition.ToString().AsEnum <LegoTransition>();
            meta.ItemRootColorTintMeta   = LegoColorTintMeta.Create(itemRootToggle);
            meta.ItemRootTargetGraphicId = itemRootToggle.targetGraphic.name;

            var itemBackground = item.Find("Item Background").GetComponent <RectTransform>();

            meta.ItemBackgroundRectMeta  = LegoRectTransformMeta.Create(itemBackground);
            meta.ItemBackgroundImageMeta = LegoImageMeta.Create(itemBackground.GetComponent <YuLegoImage>());

            var itemCheckmark = item.Find("Item Checkmark").GetComponent <RectTransform>();

            meta.ItemCheckmarkRectMeta  = LegoRectTransformMeta.Create(itemCheckmark);
            meta.ItemCheckmarkImageMeta = LegoImageMeta.Create(itemCheckmark.GetComponent <YuLegoImage>());

            var itemLabel = item.Find("Item Label").GetComponent <RectTransform>();

            meta.ItemLabelRectMeta = LegoRectTransformMeta.Create(itemLabel);
            meta.ItemLabelTextMeta = LegoTextMeta.Create(itemLabel.GetComponent <YuLegoText>());

            var scrollbar = template.Find("Scrollbar").GetComponent <RectTransform>();

            meta.ScrollbarRectMeta  = LegoRectTransformMeta.Create(scrollbar);
            meta.ScrollbarImageMeta = LegoImageMeta.Create(scrollbar.GetComponent <YuLegoImage>());

            var slidingArea = scrollbar.Find("Sliding Area").GetComponent <RectTransform>();

            meta.SlidingAreaRectMeta = LegoRectTransformMeta.Create(slidingArea);

            var slidingAreaHandle = slidingArea.Find("Handle").GetComponent <RectTransform>();

            meta.ScrollbarHandleRectMeta  = LegoRectTransformMeta.Create(slidingAreaHandle);
            meta.ScrollbarHandleImageMeta = LegoImageMeta.Create(slidingAreaHandle.GetComponent <YuLegoImage>());

            return(meta);
        }