public void Compose(List <CategoryInfo> catInfos, bool filterCompleted) { this.btnPrefab = ((!SafeLayout.IsTablet) ? this.phoneBtnPrefab : this.tabletBtnPrefab); CategoryBar.ViewConfig config = (!SafeLayout.IsTablet) ? this.phoneConfig : this.tabletConfig; this.layout.Init(config); string textByKey = LocalizationService.Instance.GetTextByKey("filter_showAllCategories"); CategoryFilterButton categoryFilterButton = this.CreateButton(); categoryFilterButton.Init(CategoryBar.ShowAllCategoryId, textByKey); this.layout.Add(categoryFilterButton); this.categories.Add(categoryFilterButton); for (int i = 0; i < catInfos.Count; i++) { CategoryFilterButton categoryFilterButton2 = this.CreateButton(); categoryFilterButton2.Init(catInfos[i].id, catInfos[i].name); this.layout.Add(categoryFilterButton2); this.categories.Add(categoryFilterButton2); } this.positioner = this.layout.transform.parent.GetComponent <ScrollElementPositioner>(); if (this.positioner != null) { List <Vector2> list = new List <Vector2>(); for (int j = 0; j < this.categories.Count; j++) { list.Add(((RectTransform)this.categories[j].transform).anchoredPosition); } this.positioner.Init(list, config.padding, config.spacing); } }
public void Init(CategoryBar.ViewConfig config) { this.viewConfig = config; this.rt = (RectTransform)base.transform; this.rt.sizeDelta = new Vector2((float)(this.viewConfig.padding * 2), this.rt.sizeDelta.y); this.nexItemPos = new Vector2((float)this.viewConfig.padding, 0f); this.count = 0; }