示例#1
0
        private void OnComponentLoaded(ILegoUI legoui)
        {
            legoui.SetParentUi(LocUI);
            ILegoComponent component = (ILegoComponent)legoui;

            if (componentMeta == null)
            {
                var bigId   = legoui.UIRect.name;
                var lowerId = "";//YuBigAssetIdMap.GetLowerId(bigId);
                var uiMeta  = metaHelper.GetMeta(lowerId);
                componentMeta = uiMeta;
            }
            component.ScrollViewId = components.Count; // 设置组件的滚动列表子项索引
            UpdateComponentAtInit(component);
            components.AddLast(component);
            DrawComponent(component);
            UpdateMaxIndexOffset();
            UpadteContentSize();

            // 调用外部委托
            onComponentBuilded?.Invoke(component);

            if (requestTaskCount > 0)
            {
                if (--requestTaskCount == 0)
                {
                    onReplaceComponents?.Invoke(components);
                    RxModelReplaceComplished();
                }
            }
        }
示例#2
0
        private void DrawComponent(ILegoComponent component)
        {
            var uiRxModel = ScRxModel.GetRxModel(component.ScrollViewId);

            if (uiRxModel == null)
            {
#if DEBUG
                string name = null;
                if (component.UIRect != null)
                {
                    name = component.UIRect.name;
                }
                Debug.LogError("DrawComponent错误,uiRxModel为null:  " + name
                               + "  " + component.ScrollViewId);
#endif
                return;
            }

            LegoBinder.Binding(component, componentMeta, uiRxModel);
            component.SetRxModel(uiRxModel);
            if (uiRxModel.SonComponentModels.Count != 0)
            {
                foreach (var sonComponent in component.SonComponentDict)
                {
                    var              bigId               = sonComponent.Key;
                    var              lowerId             = "";//YuBigAssetIdMap.GetLowerId(bigId);
                    LegoUIMeta       sonComponentMeta    = metaHelper.GetMeta(lowerId);
                    IYuLegoUIRxModel sonComponentRxModel = uiRxModel.SonComponentModels[bigId];

                    LegoBinder.Binding(sonComponent.Value, sonComponentMeta, sonComponentRxModel);
                    sonComponent.Value.SetRxModel(sonComponentRxModel);
                }
            }
            onDrawComponent?.Invoke(component, uiRxModel);
        }
        public void Init(RectTransform tUi, int speed, Action <RectTransform> pushTaskAction,
                         YuLegoUnloadTask parentTask)
        {
            taskRect = tUi;
            var uiTypeId = GetUiTypeId();

            taskMeta         = metaHelper.GetMeta(uiTypeId);
            unloadSpeed      = speed;
            m_PushTaskAction = pushTaskAction;
            _parentTask      = parentTask;
            willUnloadCount  = taskMeta.WillUnloadCount;
            sonComponentNum  = taskMeta.ComponentRefs.Count;
            sonContainerNum  = taskMeta.ContainerRefs.Count;
            _executeAble     = true;

            string GetUiTypeId()
            {
                if (!tUi.name.Contains("@"))
                {
                    return(tUi.name);
                }

                var finalId = tUi.name.Split('@').First();

                return(finalId);
            }
        }
示例#4
0
        public override void Metamorphose(LegoUIMeta uiMeta)
        {
            var textMeta = uiMeta.NextText;

            RectMeta = uiMeta.CurrentRect;
            Metamorphose(RectMeta, textMeta);
        }
        public static LegoUIMetaAsset GetAsset(LegoUIMeta uiMeta)
        {
            var asset = CreateInstance <LegoUIMetaAsset>();

            asset.UiMeta = uiMeta;
            asset.name   = uiMeta.RootMeta.TypeId;

            return(asset);
        }
示例#6
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();
            }
        }
示例#7
0
        private void TryHideOther(LegoUIMeta uIMeta)
        {
            if (uIMeta.HideTargets == null || uIMeta.HideTargets.Count == 0)
            {
                return;
            }

            foreach (var hideId in uIMeta.HideTargets)
            {
                ////var lowerId = YuBigAssetIdMap.GetLowerId(hideId);
                ////CloseView(lowerId);
            }
        }
        public override void Metamorphose(LegoUIMeta uiMeta)
        {
            if (MetamorphoseStage == LegoMetamorphoseStage.Completed)
            {
                MetamorphoseStage = LegoMetamorphoseStage.Metamorphosing;
            }

            if (progressbarMeta == null)
            {
                progressbarMeta = uiMeta.NextProgressbar;
                RectMeta        = uiMeta.CurrentRect;
            }

            switch (progressbarStatus)
            {
            case YuProgressbarMetamorphoseStatus.Progressbar:
                MetamorphoseRect(RectMeta);
                progressbarStatus = YuProgressbarMetamorphoseStatus.ImageBackground;
                break;

            case YuProgressbarMetamorphoseStatus.ImageBackground:
                ImageBackground.Metamorphose(progressbarMeta.BackgroundImageRect,
                                             progressbarMeta.BackgroundImageMeta);
                progressbarStatus = YuProgressbarMetamorphoseStatus.RectTransform_FillArea;
                break;

            case YuProgressbarMetamorphoseStatus.RectTransform_FillArea:
                YuLegoUtility.MetamorphoseRect(RectFillArea, progressbarMeta.FillAreaMeta);
                progressbarStatus = YuProgressbarMetamorphoseStatus.Image_Fill;
                break;

            case YuProgressbarMetamorphoseStatus.Image_Fill:
                ImageFill.Metamorphose(progressbarMeta.FillImageRect,
                                       progressbarMeta.FillImageMeta);

                progressbarMeta   = null;
                progressbarStatus = YuProgressbarMetamorphoseStatus.Progressbar;
                MetamorphoseStage = LegoMetamorphoseStage.Completed;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
示例#9
0
        public LegoUIMeta GetUIMetaAtPlay(string uiId)
        {
            LegoUIMeta meta = null;

            if (uiMetaDict.ContainsKey(uiId))
            {
                meta = uiMetaDict[uiId];
            }
            else
            {
                try
                {
                    //读取 Json 形式的 Meta
                    var textAsset = assetModule.Load <TextAsset>(uiId);

                    if (textAsset == null)
                    {
#if DEBUG
                        Debug.LogError("UI配置文件读取失败: " + uiId);
#endif
                        return(null);
                    }

                    var text = textAsset.text;
                    meta = UnityEngine.JsonUtility.FromJson <LegoUIMeta>(text);
                    uiMetaDict.Add(uiId, meta);
                    AssetModule.ReleaseAsset(uiId);
                }
                catch (System.Exception e)
                {
#if DEBUG
                    Debug.LogError("UI配置文件读取失败: " + uiId);
                    Debug.LogError(e.Message + e.StackTrace);
#endif
                    return(null);
                }
            }

            return(meta);
        }
 /// <summary>
 /// 构造一个乐高UI。
 /// </summary>
 /// <param name="locRect">UI所持有的游戏对象根物体。</param>
 /// <param name="pipeHandlers">UI所对应的所有UI生命周期事件处理器。</param>
 /// <param name="sons"></param>
 /// <param name="isInBack"></param>
 public void Construct
 (
     RectTransform locRect,
     List <IYuLegoUIPipelineHandler> pipeHandlers,
     List <ILegoUI> sons = null,
     bool isInBack       = false
 )
 {
     UIRect         = locRect;
     isInBackground = isInBack;
     selfMeta       = metaHelper.GetMeta(UIRect);
     TryAddCanvasGroup();
     TryAddAllSonComponent(sons);
     InitPipelineHandlers(pipeHandlers); // 生命周期处理器
     InitExternalPipeline();             // 外部生命周期
     controlStorage = LegoControlStorage.StoragePool.Take();
     GetOperateControl();
     TryAddRootButton();
     RegisterHandler();
     RegisterHandlerExtend();
     OnCreated();
 }
        public void Binding(ILegoUI ui, LegoUIMeta uiMeta, IYuLegoUIRxModel uiRxModel)
        {
            var rectMetas    = uiMeta.RectMetas;
            var elementTypes = uiMeta.ElementTypes;
            var length       = rectMetas.Count;

            for (var i = 0; i < length; i++)
            {
                var id          = rectMetas[i].Name;
                var elementType = elementTypes[i];
                var rectMeta    = rectMetas[i];

                try
                {
                    BingdngAtElementType(elementType, ui, id, uiRxModel, rectMeta);
                }
                catch (Exception e)
                {
                    Debug.LogError($"在绑定类型为{elementType}Id为{id}的目标控件时发生异常,异常信息为{e.Message + e.StackTrace}!");
                }
            }
        }
示例#12
0
        public void Metamorphose(LegoUIMeta uiMeta)
        {
            if (MetamorphoseStage == LegoMetamorphoseStage.Completed)
            {
                MetamorphoseStage = LegoMetamorphoseStage.Metamorphosing;
            }

            if (scrollViewMeta == null)
            {
                scrollViewMeta = uiMeta.NextScrollView;
                RectMeta       = uiMeta.CurrentRect;
            }

            switch (metamorphoseStatus)
            {
            case MetamorphoseStatus.ScrollView:
                YuLegoUtility.MetamorphoseRect(RectTransform, RectMeta);
                ScrollViewImage.Metamorphose(scrollViewMeta.ScrollViewImageMeta);
                metamorphoseStatus = MetamorphoseStatus.ScrollRect;
                break;

            case MetamorphoseStatus.ScrollRect:
                YuLegoUtility.MetamorphoseRect(ScrollRectRect, scrollViewMeta.ScrollRectRectMeta);
                ScrollRectImage.Metamorphose(scrollViewMeta.ScrollRectImageMeta);
                metamorphoseStatus = MetamorphoseStatus.Content;
                break;

            case MetamorphoseStatus.Content:
                YuLegoUtility.MetamorphoseRect(Content, scrollViewMeta.ContentRectMeta);
                scrollViewMeta     = null;
                metamorphoseStatus = MetamorphoseStatus.ScrollView;
                MetamorphoseStage  = LegoMetamorphoseStage.Completed;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
        public void Metamorphose(LegoUIMeta uiMeta)
        {
            if (MetamorphoseStage == LegoMetamorphoseStage.Completed)
            {
                MetamorphoseStage = LegoMetamorphoseStage.Metamorphosing;
            }

            if (rockerMeta == null)
            {
                rockerMeta = uiMeta.NextRocker;
                RectMeta   = uiMeta.CurrentRect;
            }

            switch (metamorphose)
            {
            case MetamorphoseStatus.Rocker:
                YuLegoUtility.MetamorphoseRect(RectTransform, RectMeta);

                metamorphose = MetamorphoseStatus.BackgroundImage;
                break;

            case MetamorphoseStatus.BackgroundImage:
                BgImage.Metamorphose(rockerMeta.BgImageMeta);

                metamorphose = MetamorphoseStatus.RockerImage;
                break;

            case MetamorphoseStatus.RockerImage:
                RockerImage.Metamorphose(rockerMeta.RockerImageMeta);

                metamorphose      = MetamorphoseStatus.Rocker;
                MetamorphoseStage = LegoMetamorphoseStage.Completed;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
示例#14
0
        public override void Metamorphose(LegoUIMeta uiMeta)
        {
            if (MetamorphoseStage == LegoMetamorphoseStage.Completed)
            {
                MetamorphoseStage = LegoMetamorphoseStage.Metamorphosing;
            }

            if (tButtonMeta == null)
            {
                tButtonMeta = uiMeta.NextTButton;
                RectMeta    = uiMeta.CurrentRect;
            }

            switch (tButtonStatus)
            {
            // 按钮自身变形
            case YuTButtonMetamorphoseStatus.Button:
                MetamorphoseRect(RectMeta);
                if (tButtonMeta.TransitionType == LegoTransition.ColorTint &&
                    tButtonMeta.ColorTintMeta != null)
                {
                    var colorTintMeta = tButtonMeta.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
                    };
                }

                tButtonStatus = YuTButtonMetamorphoseStatus.ButtonImage;
                break;

            case YuTButtonMetamorphoseStatus.ButtonImage:
                // 按钮附带的Image变形
                BgImage.As <YuLegoImage>().Metamorphose(tButtonMeta.ButtonImageMeta);
                tButtonStatus = YuTButtonMetamorphoseStatus.IconImage;
                break;

            case YuTButtonMetamorphoseStatus.IconImage:
                IconImage.As <YuLegoImage>().Metamorphose(tButtonMeta.IconRectMeta,
                                                          tButtonMeta.IconImageMeta);
                tButtonStatus = YuTButtonMetamorphoseStatus.SonText;
                break;

            case YuTButtonMetamorphoseStatus.SonText:
                if (tButtonMeta.IsTextActive)
                {
                    SonText.gameObject.SetActive(true);
                    SonText.Metamorphose(tButtonMeta.TextRect, tButtonMeta.TextMeta);
                }
                else
                {
                    SonText.gameObject.SetActive(false);
                }

                tButtonMeta       = null;
                tButtonStatus     = YuTButtonMetamorphoseStatus.Button;
                MetamorphoseStage = LegoMetamorphoseStage.Completed;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
示例#15
0
 public abstract void Metamorphose(LegoUIMeta uiMeta);
示例#16
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();
            }
        }
示例#17
0
        //private Sprite GetSprite(YuLegoDropdownOptionMeta optionMeta)
        //{
        //    var spriteId = optionMeta.SpriteId;

        //    if (spriteDict.ContainsKey(spriteId))
        //    {
        //        return spriteDict[spriteId].GetAsset();
        //    }

        //    var spRef = AssetModule.GetSprite(spriteId);
        //    spriteDict.Add(spriteId, spRef);
        //    return spRef.GetAsset();
        //}

        #endregion

        public override void Metamorphose(LegoUIMeta uiMeta)
        {
            if (MetamorphoseStage == LegoMetamorphoseStage.Completed)
            {
                MetamorphoseStage = LegoMetamorphoseStage.Metamorphosing;
            }

            if (dropdownMeta == null)
            {
                dropdownMeta     = uiMeta.NextDropdown;
                dropdownRectMeta = uiMeta.CurrentRect;
            }

            switch (metamorphoseStatus)
            {
            case MetamorphoseStatus.Dropdown:
                MetamorphoseRect(dropdownRectMeta);

                // 输入框自身附带Image控件变形
                SelfImage.Metamorphose(dropdownMeta.DropdownImageMeta);

                if (dropdownMeta.Transition == LegoTransition.ColorTint)
                {
                    var colorTintMeta = dropdownMeta.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
                    };
                }

                // 选项
                if (dropdownMeta.OptionMetas != null && dropdownMeta.OptionMetas.Count > 0)
                {
                    options.Clear();

                    foreach (var optionMeta in dropdownMeta.OptionMetas)
                    {
                        var optionData = new OptionData();
                        optionData.text = optionMeta.Text;
                        // todo 下拉框菜单精灵

                        //optionData.image = SpriteRouter.GetSprite(optionMeta.SpriteId);
                        options.Add(optionData);
                    }
                }

                metamorphoseStatus = MetamorphoseStatus.Label;
                break;

            case MetamorphoseStatus.Label:
                Label.Metamorphose(dropdownMeta.LabelRectMeta, dropdownMeta.LabelTextMeta);
                metamorphoseStatus = MetamorphoseStatus.Arrow;
                break;

            case MetamorphoseStatus.Arrow:
                Arrow.Metamorphose(dropdownMeta.ArrowRectMeta, dropdownMeta.ArrowImageMeta);
                metamorphoseStatus = MetamorphoseStatus.Template;
                break;

            case MetamorphoseStatus.Template:
                TemplateImage.Metamorphose(dropdownMeta.TemplateRectMeta, dropdownMeta.TemplateImageMeta);
                metamorphoseStatus = MetamorphoseStatus.Viewport;
                break;

            case MetamorphoseStatus.Viewport:
                ViewportImage.Metamorphose(dropdownMeta.ViewPortRectMeta, dropdownMeta.ViewPortImageMeta);
                metamorphoseStatus = MetamorphoseStatus.Content;
                break;

            case MetamorphoseStatus.Content:
                YuLegoUtility.MetamorphoseRect(Content, dropdownMeta.ContentRectMeta);
                metamorphoseStatus = MetamorphoseStatus.Item;
                break;

            case MetamorphoseStatus.Item:
                if (dropdownMeta.ItemTransition == LegoTransition.ColorTint)
                {
                    var colorTintMeta = dropdownMeta.ItemRootColorTintMeta;

                    Item.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
                    };
                }

                YuLegoUtility.MetamorphoseRect(Item.RectTransform, dropdownMeta.ItemRootRectMeta);
                metamorphoseStatus = MetamorphoseStatus.ItemBackground;
                break;

            case MetamorphoseStatus.ItemBackground:
                ItemBackground.Metamorphose(dropdownMeta.ItemBackgroundRectMeta,
                                            dropdownMeta.ItemBackgroundImageMeta);
                metamorphoseStatus = MetamorphoseStatus.ItemCheckmark;
                break;

            case MetamorphoseStatus.ItemCheckmark:
                ItemCheckmark.Metamorphose(dropdownMeta.ItemCheckmarkRectMeta,
                                           dropdownMeta.ItemCheckmarkImageMeta);
                metamorphoseStatus = MetamorphoseStatus.ItemLabel;
                break;

            case MetamorphoseStatus.ItemLabel:
                ItemLabel.Metamorphose(dropdownMeta.ItemLabelRectMeta,
                                       dropdownMeta.ItemLabelTextMeta);
                metamorphoseStatus = MetamorphoseStatus.Scrollbar;
                break;

            case MetamorphoseStatus.Scrollbar:
                ScrollbarImage.Metamorphose(dropdownMeta.ScrollbarRectMeta,
                                            dropdownMeta.ScrollbarImageMeta);
                metamorphoseStatus = MetamorphoseStatus.SlidingArea;
                break;

            case MetamorphoseStatus.SlidingArea:
                YuLegoUtility.MetamorphoseRect(SlidingArea, dropdownMeta.SlidingAreaRectMeta);
                metamorphoseStatus = MetamorphoseStatus.Handle;
                break;

            case MetamorphoseStatus.Handle:
                HandleImage.Metamorphose(dropdownMeta.ScrollbarHandleRectMeta,
                                         dropdownMeta.ScrollbarHandleImageMeta);

                dropdownMeta       = null;
                dropdownRectMeta   = null;
                metamorphoseStatus = MetamorphoseStatus.Dropdown;
                MetamorphoseStage  = LegoMetamorphoseStage.Completed;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
示例#18
0
        public override void Metamorphose(LegoUIMeta uiMeta)
        {
            if (MetamorphoseStage == LegoMetamorphoseStage.Completed)
            {
                MetamorphoseStage = LegoMetamorphoseStage.Metamorphosing;
            }

            if (toggleMeta == null)
            {
                toggleMeta = uiMeta.NextToggle;
                RectMeta   = uiMeta.CurrentRect;
            }

            switch (metamorphoseStatus)
            {
            case YuLegoToggleMetamorphoseStatus.Toggle:
                YuLegoUtility.MetamorphoseRect(RectTransform, uiMeta.CurrentRect);

                if (toggleMeta.Transition == LegoTransition.ColorTint)
                {
                    var colorTintMeta = toggleMeta.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
                    };
                }

                SoundEffectId      = toggleMeta.SoundId;
                metamorphoseStatus = YuLegoToggleMetamorphoseStatus.ImageBackground;
                break;

            case YuLegoToggleMetamorphoseStatus.ImageBackground:
                BackgroundImage.Metamorphose(toggleMeta.BackgroundRectMeta,
                                             toggleMeta.BackgroundImageMeta);
                metamorphoseStatus = YuLegoToggleMetamorphoseStatus.ImageCheck;
                break;

            case YuLegoToggleMetamorphoseStatus.ImageCheck:
                CheckmarkImage.Metamorphose(toggleMeta.CheckmarkRectMeta,
                                            toggleMeta.CheckMarkImageMeta);
                metamorphoseStatus = YuLegoToggleMetamorphoseStatus.SonText;
                break;

            case YuLegoToggleMetamorphoseStatus.SonText:
                metamorphoseStatus = YuLegoToggleMetamorphoseStatus.Toggle;
                Text.Metamorphose(toggleMeta.TextRect, toggleMeta.TextMeta);

                toggleMeta         = null;
                metamorphoseStatus = YuLegoToggleMetamorphoseStatus.Toggle;
                MetamorphoseStage  = LegoMetamorphoseStage.Completed;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
示例#19
0
        public override void Metamorphose(LegoUIMeta uiMeta)
        {
            if (MetamorphoseStage == LegoMetamorphoseStage.Completed)
            {
                MetamorphoseStage = LegoMetamorphoseStage.Metamorphosing;
            }

            if (ButtonMeta == null)
            {
                ButtonMeta = uiMeta.NextButton;
                RectMeta   = uiMeta.CurrentRect;
            }

            switch (metamorphoseStatus)
            {
            // 按钮自身变形
            case MetamorphoseStatus.Button:
                MetamorphoseRect(RectMeta);
                if (ButtonMeta.TransitionType == LegoTransition.ColorTint &&
                    ButtonMeta.ColorTintMeta != null)
                {
                    var colorTintMeta = ButtonMeta.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
                    };
                }

                SoundEffectId = ButtonMeta.ButtonSoundId;

                metamorphoseStatus = MetamorphoseStatus.ButtonImage;
                break;

            case MetamorphoseStatus.ButtonImage:
                // 按钮附带的Image变形
                BgImage.As <YuLegoImage>().Metamorphose(ButtonMeta.ButtonImageMeta);
                if (ButtonMeta.IsNonRectangularButtonImage)
                {
                    IsNonRectangularButtonImage = true;
                    BgImage.As <YuLegoImage>().alphaHitTestMinimumThreshold =
                        ButtonMeta.ImageAlphaHitTestMinimumThreshold;
                }
                metamorphoseStatus = MetamorphoseStatus.SonText;
                break;

            case MetamorphoseStatus.SonText:
                if (ButtonMeta.IsTextActive)
                {
                    SonText.gameObject.SetActive(true);
                    SonText.Metamorphose(ButtonMeta.TextRect, ButtonMeta.TextMeta);
                }
                else
                {
                    SonText.gameObject.SetActive(false);
                }

                metamorphoseStatus = MetamorphoseStatus.Button;
                MetamorphoseStage  = LegoMetamorphoseStage.Completed;
                break;
            }
        }