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);
                }
            }
        }
Ejemplo n.º 2
0
        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));
            }
        }
Ejemplo n.º 3
0
 protected override void ChangeTabEventRaised(InventoryTabTypeSO tabType)
 {
     //
     FillInventory(tabType.TabType);
 }
Ejemplo n.º 4
0
 public void RaiseEvent(InventoryTabTypeSO item) => OnEventRaised?.Invoke(item);