private void TryAddRootButton()
        {
            if (rootButton != null)
            {
                return;
            }

            rootButton = UIRect.Find("Button_Root")?.GetComponent <YuLegoButton>();
            if (rootButton == null)
            {
                return;
            }

            rootButton.gameObject.layer = UIRect.gameObject.layer;

            if (!selfMeta.IsBlankClose)
            {
                rootButton.gameObject.SetActive(false);
                return;
            }

            rootButton.Construct(this);
            //            defaultRootClickHandler.OperateUi = this;
            rootButton.RegisterHandler(LegoInteractableType.OnPointerClick, defaultRootClickHandler);
            rootButton.SonText.gameObject.SetActive(false);
        }
示例#2
0
        private void TryUpdateButtonSpriteSwap()
        {
            if (lastButton != null && lastButton.ButtonMeta?.SpriteSwapMeta != null)
            {
                var lastNormalSpriteId = lastButton.ButtonMeta.SpriteSwapMeta.TargetGraphic;
                BgImage.SpriteId = lastNormalSpriteId;
            }

            lastButton = this;
            if (ButtonMeta?.SpriteSwapMeta == null)
            {
                return;
            }

            BgImage.SpriteId = ButtonMeta.SpriteSwapMeta.PressedSprite;
        }
        public static LegoButtonMeta Create(YuLegoButton button)
        {
            var meta = new LegoButtonMeta
            {
                Interactable   = button.interactable,
                TransitionType = button.transition.ToString().AsEnum <LegoTransition>(),
                ButtonSoundId  = button.SoundEffectId,
                IsNonRectangularButtonImage = button.IsNonRectangularButtonImage
            };

            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);

            return(meta);
        }