Exemplo n.º 1
0
        private void AddPlaneToggleMeta(Transform transform)
        {
            var planeToggleMeta = LegoPlaneToggleMeta
                                  .Create(transform.GetComponent <YuLegoPlaneToggle>());

            PlaneToggleMetas.Add(planeToggleMeta);
        }
Exemplo n.º 2
0
        public override void Metamorphose(LegoUIMeta uiMeta)
        {
            if (MetamorphoseStage == LegoMetamorphoseStage.Completed)
            {
                MetamorphoseStage = LegoMetamorphoseStage.Metamorphosing;
            }

            if (PlaneToggleMeta == null)
            {
                PlaneToggleMeta = uiMeta.NextPlaneToggle;
                RectMeta        = uiMeta.CurrentRect;
            }

            switch (planeMetamorphoseStatus)
            {
            case MetamorphoseStatus.Toggle:
                MetamorphoseRect(RectMeta);
                if (PlaneToggleMeta.TransitionType == LegoTransition.ColorTint &&
                    PlaneToggleMeta.ColorTintMeta != null)
                {
                    var colorTintMeta = PlaneToggleMeta.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
                    };
                }

                IsOn                    = PlaneToggleMeta.Ison;
                Interactable            = PlaneToggleMeta.Interactable;
                SoundEffectId           = PlaneToggleMeta.SoundId;
                planeMetamorphoseStatus = MetamorphoseStatus.SelfImage;
                break;

            case MetamorphoseStatus.SelfImage:
                ToggleImage.As <YuLegoImage>().Metamorphose(PlaneToggleMeta.ToggleImageMeta);
                planeMetamorphoseStatus = MetamorphoseStatus.Background;
                break;

            case MetamorphoseStatus.Background:
                FrontImage.As <YuLegoImage>().Metamorphose(PlaneToggleMeta
                                                           .ImageFrontPointRectMeta, PlaneToggleMeta.ImageFrontPointImageMeta);
                planeMetamorphoseStatus = MetamorphoseStatus.Toggle;
                MetamorphoseStage       = LegoMetamorphoseStage.Completed;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
        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);
        }