public void fillTab(InventoryTabType tabType, bool isSelected, TabEventChannelSO changeTabEvent) { _tabName.StringReference = tabType.TabName; _actionButton.interactable = !isSelected; _actionButton.onClick.RemoveAllListeners(); _actionButton.onClick.AddListener(() => changeTabEvent.RaiseEvent(tabType)); }
public virtual void FillTab(InventoryTabTypeSO tabType, bool isSelected, TabEventChannelSO changeTabEvent) { image.sprite = tabType.TabIcon; tabName.StringReference = tabType.TabName; // _actionButton.interactable = !isSelected; if (isSelected) { // image.color = _selectedIconColor; } else { // image.color = _deselectedIconColor; } if (onTabDeselected != null) { onTabSelected.RemoveAllListeners(); onTabSelected.AddListener(() => changeTabEvent.RaiseEvent(tabType)); } }
public void FillTabs(List <InventoryTabTypeSO> typesList, InventoryTabTypeSO selectedType, TabEventChannelSO changeTabEvent) { int maxCount = Mathf.Max(typesList.Count, tabButtons.Count); for (int i = 0; i < maxCount; i++) { if (i < typesList.Count) { if (i >= tabButtons.Count) { Debug.Log("Maximum tabs reached"); // TODO create new tabs if the user allows it. } bool isSelected = typesList[i] == selectedType; // fill tabButtons[i].FillTab(typesList[i], isSelected, changeTabEvent); tabButtons[i].gameObject.SetActive(true); } else if (i < tabButtons.Count) { // Deactivate tabButtons[i].gameObject.SetActive(false); } } }
public void FillTabs(List <InventoryTabType> typesList, InventoryTabType selectedType, TabEventChannelSO changeTabEvent) { if (instantiatedGameObjects == null) { instantiatedGameObjects = new List <InventoryTypeTabFiller>(); } if (gameObject.GetComponent <VerticalLayoutGroup>() != null) { gameObject.GetComponent <VerticalLayoutGroup>().enabled = true; } int maxCount = Mathf.Max(typesList.Count, instantiatedGameObjects.Count); for (int i = 0; i < maxCount; i++) { if (i < typesList.Count) { if (i >= instantiatedGameObjects.Count) { Debug.Log("Maximum tabs reached"); } bool isSelected = typesList[i] == selectedType; //fill instantiatedGameObjects[i].fillTab(typesList[i], isSelected); instantiatedGameObjects[i].gameObject.SetActive(true); } else if (i < instantiatedGameObjects.Count) { //Desactive instantiatedGameObjects[i].gameObject.SetActive(false); } } StartCoroutine(waitBeforeDesactiveLayout()); }