void AddItems() { for (int i = 0; i < ItemList.Count; ++i) //Creates building buttons { GameObject newButton = Instantiate(prefab, ContentPanel) as GameObject; BuildingButton buildingButton = newButton.GetComponent <BuildingButton>(); buildingButton.Setup(ItemList[i], this); //Sets the item data for each building button } }
/// <summary> /// Add building button to the scrollview /// </summary> private void AddBuildingButtons() { if (scrollbarVertical.verticalScrollbar.value == 0) { scrollbarVertical.verticalScrollbar.value = 0.0000001f; int a = 0; while (a < 7) { for (int i = 0; i < itemList.Count; i++) { Item item = itemList[i]; GameObject newButton = buttonObjectPool.GetObject(); newButton.transform.SetParent(contentPanel); BuildingButton buildingButton = newButton.GetComponent <BuildingButton>(); buildingButton.Setup(item); } a++; } } }