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));
 }
Example #2
0
    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, changeTabEvent);
                instantiatedGameObjects[i].gameObject.SetActive(true);
            }
            else if (i < instantiatedGameObjects.Count)
            {
                //Desactive
                instantiatedGameObjects[i].gameObject.SetActive(false);
            }
        }
        StartCoroutine(waitBeforeDesactiveLayout());
    }