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(); } } }
private void BindSonComponentRxmodl(IYuLegoUIRxModel rxModel, ILegoUI component) { foreach (var sonComponent in component.SonComponentDict) { rxModel.SonComponentModels.Add(sonComponent.Key, sonComponent.Value.RxModel); } }
private void BindingInputField(ILegoUI ui, string id, IYuLegoUIRxModel uiRxModel, LegoRectTransformMeta rectMeta) { var binder = binderDict[typeof(YuLegoInputField)]; var oldModel = ui.RxModel.GetControlRxModel <YuLegoInputFieldRxModel>(id); binder.UnBinding(oldModel); var inputField = ui.GetControl <YuLegoInputField>(id); var model = uiRxModel.GetControlRxModel <YuLegoInputFieldRxModel>(id); binder.Binding(inputField, model, rectMeta); }
private void BindingProgressbar(ILegoUI ui, string id, IYuLegoUIRxModel uiRxModel, LegoRectTransformMeta rectMeta) { var binder = binderDict[typeof(YuLegoProgressbar)]; var oldModel = ui.RxModel.GetControlRxModel <YuLegoProgressbarRxModel>(id); binder.UnBinding(oldModel); var progressbar = ui.GetControl <YuLegoProgressbar>(id); var model = uiRxModel.GetControlRxModel <YuLegoProgressbarRxModel>(id); binder.Binding(progressbar, model, rectMeta); }
private void BindingPlaneToggle(ILegoUI ui, string id, IYuLegoUIRxModel uiRxModel, LegoRectTransformMeta rectMeta) { var binder = binderDict[typeof(YuLegoPlaneToggle)]; var oldModel = ui.RxModel.GetControlRxModel <YuLegoPlaneToggleRxModel>(id); binder.UnBinding(oldModel); var planeToggle = ui.GetControl <YuLegoPlaneToggle>(id); var model = uiRxModel.GetControlRxModel <YuLegoPlaneToggleRxModel>(id); binder.Binding(planeToggle, model, rectMeta); }
private void BindingTButton(ILegoUI ui, string id, IYuLegoUIRxModel uiRxModel, LegoRectTransformMeta rectMeta) { var binder = binderDict[typeof(YuLegoTButton)]; var oldModel = ui.RxModel.GetControlRxModel <YuLegoTButtonRxModel>(id); binder.UnBinding(oldModel); var button = ui.GetControl <YuLegoTButton>(id); var model = uiRxModel.GetControlRxModel <YuLegoTButtonRxModel>(id); binder.Binding(button, model, rectMeta); }
private void BindingRawImage(ILegoUI ui, string id, IYuLegoUIRxModel uiRxModel, LegoRectTransformMeta rectMeta) { var binder = binderDict[typeof(YuLegoRawImage)]; var oldModel = ui.RxModel.GetControlRxModel <YuLegoRawImageRxModel>(id); binder.UnBinding(oldModel); var rawImage = ui.GetControl <YuLegoRawImage>(id); var model = uiRxModel.GetControlRxModel <YuLegoRawImageRxModel>(id); binder.Binding(rawImage, model, rectMeta); }
private void BindingText(ILegoUI ui, string id, IYuLegoUIRxModel uiRxModel, LegoRectTransformMeta rectMeta) { var binder = binderDict[typeof(YuLegoText)]; var oldModel = ui.RxModel.GetControlRxModel <YuLegoTextRxModel>(id); binder.UnBinding(oldModel); var text = ui.GetControl <YuLegoText>(id); var model = uiRxModel.GetControlRxModel <YuLegoTextRxModel>(id); binder.Binding(text, model, rectMeta); }
private void TryInvokeViewUILogicer(ILegoUI ui) { var logicer = CodeLoader.GetLogic(ui.UIRect.name); if (logicer == null) { return; } var ctx = TakeContext(); ctx.Init(ui); logicer.Init(ctx); uiViewLogicerDic.Add(ui.UIRect.name.ToLower(), logicer); }
private void TryInvokeComponentUILogicer(ILegoUI ui) { var logicer = CodeLoader.GetLogic(ui.UIRect.name); if (logicer == null) { return; } var ctx = TakeContext(); ctx.Init(ui); logicer.Init(ctx); if (!uiComponentLogicerListsDic.ContainsKey(ui.UIRect.name)) { uiComponentLogicerListsDic.Add(ui.UIRect.name, new List <IViewLogic>()); } uiComponentLogicerListsDic[ui.UIRect.name].Add(logicer); }
private void BindingImage(ILegoUI ui, string id, IYuLegoUIRxModel uiRxModel, LegoRectTransformMeta rectMeta) { var binder = binderDict[typeof(YuLegoImage)]; var oldModel = ui.RxModel.GetControlRxModel <YuLegoImageRxModel>(id); if (oldModel != null) { binder.UnBinding(oldModel); } #if DEBUG else { string uiName = null; if (ui?.UIRect != null) { uiName = ui.UIRect.name; } Debug.LogError("BindingImage错误,oldModel为null" + uiName + " " + id); } #endif var image = ui.GetControl <YuLegoImage>(id); var model = uiRxModel.GetControlRxModel <YuLegoImageRxModel>(id); if (model != null) { binder.Binding(image, model, rectMeta); } #if DEBUG else { string uiName = null; if (ui?.UIRect != null) { uiName = ui.UIRect.name; } Debug.LogError("BindingImage错误,Model为null" + uiName + " " + id); } #endif }
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}!"); } } }
public void Construct(ILegoUI locUI, object obj = null) { #if DEBUG if (Content.childCount > 0) { Content.DeleteAllChild(); } #endif LocUI = locUI; //生命周期 var pipelineHandlerList = PipelineRouter.GetHandlers(RectTransform.name.Split('@')[0]); InitPipelineHandlerDic(pipelineHandlerList); //读取滚动视图元数据初始化控件基本设置 var locUIMeta = MetaHelper.GetMeta(transform.parent.name); scrollViewMeta = locUIMeta.GetScrollViewMeta(name); if (scrollViewMeta.IsNotInitSonComponent) { return; } //初始化滚动视图数据模型相关操作 InitScrollViewRxModel(); //初始化滚动视图交互操作 InitMetaInfo(scrollViewMeta); InitScrollRect(); //添加初始子项 TryRequestBuildComponent(); if (RequireCount == 0) { TryInvokeOnCreated(); } }
public void Init(ILegoUI ui) { MapUI = ui; }
public void SetParentUi(ILegoUI parent) { ParentUI = parent; }
public void Construct(ILegoUI locUI, object obj = null) { LocUI = locUI; //rockerPosition = RockerImage.RectTransform.localPosition; }
private void SetViewSonComponentRxModel(IYuLegoUIRxModel rxModel, ILegoUI component) { rxModel.InitRxModel(); component.SetRxModel(rxModel); }
/// <summary> /// 绑定数据模型与脚本 /// </summary> /// <param name="rxModel"></param> /// <param name="view"></param> private void SetViewRxModel(IYuLegoUIRxModel rxModel, ILegoUI view) { rxModel.InitRxModel(); view.SetRxModel(rxModel); }
public virtual void Construct(ILegoUI locUI, object obj = null) { LocUI = locUI; }
private void BingdngAtElementType(LegoUIType elementType, ILegoUI ui, string id, IYuLegoUIRxModel uiRxModel, LegoRectTransformMeta rectMeta) { switch (elementType) { case LegoUIType.Text: BindingText(ui, id, uiRxModel, rectMeta); break; case LegoUIType.Image: BindingImage(ui, id, uiRxModel, rectMeta); break; case LegoUIType.RawImage: BindingRawImage(ui, id, uiRxModel, rectMeta); break; case LegoUIType.Button: BindingButton(ui, id, uiRxModel, rectMeta); break; case LegoUIType.TButton: BindingTButton(ui, id, uiRxModel, rectMeta); break; case LegoUIType.InputField: BindingInputField(ui, id, uiRxModel, rectMeta); break; case LegoUIType.Slider: BindingSlider(ui, id, uiRxModel, rectMeta); break; case LegoUIType.Progressbar: BindingProgressbar(ui, id, uiRxModel, rectMeta); break; case LegoUIType.Toggle: BindingToggle(ui, id, uiRxModel, rectMeta); break; case LegoUIType.Tab: break; case LegoUIType.Dropdown: BindingDropdown(ui, id, uiRxModel, rectMeta); break; case LegoUIType.Rocker: break; case LegoUIType.Grid: break; case LegoUIType.ScrollView: break; case LegoUIType.None: break; case LegoUIType.InlineText: break; case LegoUIType.PlaneToggle: BindingPlaneToggle(ui, id, uiRxModel, rectMeta); break; case LegoUIType.Component: break; case LegoUIType.Container: break; case LegoUIType.View: break; default: throw new ArgumentOutOfRangeException(nameof(elementType), elementType, null); } }
private void TryUnBingdngAtElementType(LegoUIType elementType, ILegoUI ui, string id, IYuLegoUIRxModel uiRxModel) { }
public override void Construct(ILegoUI locUI, object obj = null) { base.Construct(locUI); onValueChanged.AddListener(OnValueChanged); }
public void Reset() { MapUI = null; }