Esempio n. 1
0
        private void OnViewBuilded(string lowerId, string bigId, LegoBuildTask buildTask)
        {
            var uiRect = buildTask.RootRect;
            //            loadingTaskIds.Remove(lowerId);
            ILegoView view = CodeLoader.GetView(uiRect);

            views.Add(lowerId, view);
            var uiMeta = MetaHelper.GetMeta(uiRect);

            //绑定子组件
            tempUis.Clear();
            foreach (var sonRef in uiMeta.ComponentRefs)
            {
                if (!uiLogicMap.ContainsKey(sonRef.LogicId))
                {
                    throw new Exception($"视图{bigId}的子组件{sonRef.LogicId}无法找到!");
                }

                var component = uiLogicMap[sonRef.LogicId];
                component.SetParentUi(view);
                tempUis.Add(component);
            }

            //数据模型与 UI 类型实例绑定
            var rxModel = (IYuLegoUIRxModel)ModelLoader.LoadModel(bigId);

            SetViewRxModel(rxModel, view);

            //UI 实体Rect,周期管理类型,子组件与 UI 脚本类型实例绑定
            var pipelineHandlers = PipelineLoader.GetHandlers(bigId);

            if (buildTask.IsInBackground)
            {
                view.Construct(uiRect, pipelineHandlers, tempUis, true);
            }
            else
            {
                view.Construct(uiRect, pipelineHandlers, tempUis);
            }

            //控制器
            TryInvokeViewUILogicer(view);

            // 修正界面的Z轴深度
            AddViewToDepthViews(view, uiMeta.ViewType);

            //数据模型数据与 UI 脚本类型实例绑定
            LegoBinder.Binding(view, uiMeta, rxModel);

            //构建完成回调
            buildTask.UiBuildCallback?.Invoke(view);

            //触发界面创建完成事件
            U3DEventModule.TriggerEvent(ProjectCoreEventCode.View_Created, view, null);
            view.ShowDefault();
        }
        public void PushView(ILegoView view)
        {
            if (Math.Abs(BottomZ) < _layerSpacing)
            {
                var z = _views.Count * _everyZ;

                view.DepthZ = -z;
                _views.AddLast(view);
                return;
            }


            NextLayer.BackShift(_layerSpacing);
            _layerSpacing = _layerSpacing * 2;
            PushView(view);
        }
Esempio n. 3
0
        private void AddViewToDepthViews(ILegoView view, LegoViewType viewType)
        {
            var layer = LegoUIMounter.uiLayers[viewType];

            layer.PushView(view);
        }