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 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 LegoTextMeta Create(YuLegoText text)
        {
            var meta = new LegoTextMeta
            {
                StyleId       = text.StyleId,
                Content       = text.text,
                RaycastTarget = text.raycastTarget,

                FontId    = text.font.name,
                FontStyle = text.fontStyle.ToString().AsEnum <LegoTextFontStyle>(),
                FontSize  = text.fontSize,
                ////Color = YuColor.Create(text.color),
                RichText    = text.supportRichText,
                LineSpacing = text.lineSpacing,

                VerticalOverflow   = text.verticalOverflow.ToString().AsEnum <LegoTextVerticalOverflow>(),
                HorizontalOverflow = text.horizontalOverflow
                                     .ToString().AsEnum <LegoTextHorizontalOverflow>(),

                BestFit         = text.resizeTextForBestFit,
                Alignment       = text.alignment.ToString().AsEnum <LegoTextAlignment>(),
                AlignByGeometry = text.alignByGeometry
            };

            return(meta);
        }
Exemple #4
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);
        }
Exemple #5
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();
        }
Exemple #6
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);
        }
Exemple #7
0
        private void AddTextMeta(Transform transform)
        {
            var textMeta = LegoTextMeta.Create(transform.GetComponent <YuLegoText>());

            TextMetas.Add(textMeta);
        }