示例#1
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);
        }
示例#2
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();
                }
            }
        }
示例#3
0
        private void UpdateComponentEvery(ILegoComponent component)
        {
            var componentPosition = GetItemPosition(component.ScrollViewId);

            component.UIRect.localPosition = componentPosition;
            component.UIRect.gameObject.SetActive(true);
#if DEBUG
            component.UIRect.name = componentId + "_" + component.ScrollViewId;
#endif
        }
示例#4
0
 private void UpdateComponentAtInit(ILegoComponent component)
 {
     component.UIRect.SetParent(Content);
     component.UIRect.AsLeftTop();
     component.UIRect.pivot            = new Vector2(0f, 1f);
     component.UIRect.localScale       = Vector3.one;
     component.UIRect.sizeDelta        = new Vector2(componentMeta.RootMeta.Width, componentMeta.RootMeta.Height);
     component.UIRect.gameObject.layer = Content.gameObject.layer;
     UpdateComponentEvery(component);
 }
示例#5
0
        public void Restore(ILegoComponent component)
        {
            var id = component.Id;

            if (!componentCache.ContainsKey(id))
            {
                componentCache.Add(id, new Queue <ILegoComponent>());
            }

            componentCache[id].Enqueue(component);
            component.UIRect.SetParent(componentPoolRect);
        }
示例#6
0
 public void Restore(ILegoComponent component) => uILoader.Restore(component);