async Task <UIComponent> AddWindow(string winName, GameObject go = null) { var type = World.Instance.GetComponentType($"View_{winName}Component"); if (type == null) { Debug.LogError($"找不到对应类型---View_{winName}Component"); return(null); } //生成窗口 var component = World.Main.GetComponent <UIManagerComponent>().Entity .AddChild(type, IDGenerater.GetID(winName)) as UIComponent; if (component == null) { return(null); } component.Connect <UIComponent>(); if (go == null) { go = await Create(winName); } //初始化窗口 component.rectTransform = go.transform as RectTransform; //如果有动画组件就挂载动画组件 if (go.TryGetComponent <UISetting>(out var uiSetting)) { component.Entity.AddComponent <UIAnimaComponent>().From(uiSetting); component.ModuleUI = uiSetting.ModuleUI; go.SetActive(uiSetting.Active); Object.Destroy(uiSetting); } component.ViewName = winName; UiItems.Add(winName, component); UiItemsType.Add(type, component); if (BaseIndex == -1) { BaseIndex = go.transform.GetSiblingIndex(); } //调用这个窗口的初始化系统 World.Instance.RunSystemOfTagType(SystemType.UICreate, component.Entity); return(component); }
public override void BeginDialog() { base.BeginDialog(); if (UiItems.Any()) { var uiItem = UiItems.First(); if (uiItem is RecordEntryFormViewModel) { var entryForm = (RecordEntryFormViewModel)uiItem; entryForm.LoadFormSections(); //in the ui grids load asynch when the ui tries to bind to them //so need to do it manually to get it to load in script foreach (var field in entryForm.FieldViewModels) { if (field is EnumerableFieldViewModel) { var fm = (EnumerableFieldViewModel)field; var loadIt = fm.DynamicGridViewModel.GridRecords; } } } } }
public virtual void RemoveFromUi(ViewModelBase viewModel) { ApplicationController.DoOnMainThread(() => UiItems.Remove(viewModel)); }
public virtual void LoadToUi(ViewModelBase viewModel) { ApplicationController.DoOnMainThread(() => UiItems.Add(viewModel)); }
public ProductModel GetProduct(int index) { return(UiItems.SelectMany(item => item).ToList()[index]); }
public List <ProductModel> GetProducts() { return(UiItems.SelectMany(item => item).ToList()); }
public int ProductsCount() { return(UiItems.SelectMany(item => item).Count()); }