Example #1
0
    void Start()
    {
        PlayerCharacterAmount = 1;
        EnemyCharacterAmount  = 1;

        panels = GameObject.FindGameObjectsWithTag("Panel");
        texts  = GameObject.FindGameObjectsWithTag("Text");

        texts[0].GetComponent <Text>().text = PlayerCharacterAmount.ToString();
        texts[1].GetComponent <Text>().text = EnemyCharacterAmount.ToString();

        inputs.Add(FindObjectOfType <InputField>());
        dropdowns.Add(FindObjectOfType <Dropdown>());
    }
Example #2
0
    public void DecreasePlayerAmount()
    {
        if (PlayerCharacterAmount > 1)
        {
            PlayerCharacterAmount--;

            texts[0].GetComponent <Text>().text = PlayerCharacterAmount.ToString();

            Destroy(inputs[inputs.Count - 1].gameObject);
            inputs.RemoveAt(inputs.Count - 1);

            Destroy(dropdowns[dropdowns.Count - 1].gameObject);
            dropdowns.RemoveAt(dropdowns.Count - 1);
        }
    }
Example #3
0
    public void IncreasePlayerAmount()
    {
        if (PlayerCharacterAmount < 5)
        {
            PlayerCharacterAmount++;

            texts[0].GetComponent <Text>().text = PlayerCharacterAmount.ToString();

            GameObject nameObject = Instantiate(namePrefab) as GameObject;
            nameObject.transform.SetParent(panels[0].transform);
            inputs.Add(nameObject.GetComponent <InputField>());

            GameObject classObject = Instantiate(classPrefab) as GameObject;
            classObject.transform.SetParent(panels[1].transform);
            dropdowns.Add(classObject.GetComponent <Dropdown>());
        }
    }