Пример #1
0
    public void SetupForm(int numPlayers)
    {
        contentWindow          = transform.Find("Scroll View").Find("Viewport").Find("Content").gameObject;
        contentWindowTransform = contentWindow.GetComponent <RectTransform>();

        inputFields = new List <TMP_InputField>();

        for (int i = 0; i < numPlayers; i++)
        {
            IncreaseContentSize();
            PlayerForm playerForm = Instantiate(playerFormPrefab).GetComponent <PlayerForm>();
            playerForm.SetAnswerName((i).ToString());
            playerForm.transform.SetParent(contentWindow.transform);
            playerForm.SetNameText("P" + (i + 1).ToString() + ":");
            float height = contentWindowTransform.rect.height - (playerFormHeight / 2);
            playerForm.transform.localPosition = new Vector3(0, -height);

            inputFields.Add(playerForm.transform.Find(i.ToString()).GetComponent <TMP_InputField>());
        }

        inputFields[currentlySelectedInput].Select();
    }