Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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));
 }
Ejemplo n.º 5
0
 public ProductModel GetProduct(int index)
 {
     return(UiItems.SelectMany(item => item).ToList()[index]);
 }
Ejemplo n.º 6
0
 public List <ProductModel> GetProducts()
 {
     return(UiItems.SelectMany(item => item).ToList());
 }
Ejemplo n.º 7
0
 public int ProductsCount()
 {
     return(UiItems.SelectMany(item => item).Count());
 }