Exemplo n.º 1
0
    public void OnOpen()
    {
        if (M_BuildingManager.IsBuildingStarted())
        {
            M_BuildingManager.SQuitBuilding();
        }



        List <DAT_Building> buildings = M_BuildingManager.SGetAvailableBuildings();

        List <GameObject> rows = new List <GameObject>();
        int i = 0;

        foreach (DAT_Building building in buildings)
        {
            GameObject temp = Instantiate(elemPrefab);
            temp.GetComponent <UI_ElemBuilding>().Setup(building);

            if (i % 2 == 0)
            {
                temp.GetComponent <Image>().color = elemBgColorA;
            }
            else
            {
                temp.GetComponent <Image>().color = elemBgColorB;
            }
            i++;
            rows.Add(temp);
        }
        GUIUtils.AddElementsToCleanYScrollContainer(container, rows);

        foreach (UI_ElemBuilding elem in container.transform.GetComponentsInChildren <UI_ElemBuilding>())
        {
            elem.Setup();
        }
        buildingDesc.SetActive(false);
    }