Esempio n. 1
0
    void createHeaderMenu()
    {
        for (int i = 0; i < playerParts.Length + 1; i++)
        {
            GameObject option;
            if (i == 0)
            {
                //Create icon "All Parts"
                option = Instantiate(firstOption);
            }
            else if (i < (playerParts.Length))
            {
                //Middle Content
                option = Instantiate(middleOption);
            }
            else
            {
                //Last Content
                option = Instantiate(lastOption);
            }
            option.transform.parent = this.transform;

            //Set Info
            OptionControl optionControl = option.GetComponent <OptionControl>();
            Sprite        levelIconBG;
            string        nameOption;

            if (i == 0)
            {
                nameOption  = "Everything";
                levelIconBG = Resources.Load <Sprite>("UI/header/All");
            }
            else
            {
                nameOption  = playerParts[i - 1].ToString();
                levelIconBG = Resources.Load <Sprite>("UI/header/" + playerParts[i - 1].ToString());
            }

            if (i == 0)
            {
                optionControl.setSelectOption(true);
            }

            optionControl.setOptionName(nameOption);
            optionControl.setOptionImage(levelIconBG);
            optionControl.textBox.active = false;
            optionsArray.Add(option);
        }

        activateOption(0);
    }