Exemplo n.º 1
0
    private void CreateButton(ButtonData buttonData)
    {
        GameObject buttonCopy = Instantiate(buttonPrefab);

        buttonCopy.transform.SetParent(buttonHolder);
        buttonCopy.transform.localScale = Vector3.one;

        var txt    = buttonCopy.GetComponentInChildren <Text>();
        var button = buttonCopy.GetComponent <Button>();

        Action fireAndClose = () =>
        {
            buttonData.Action();
            dialogBox.SetActive(false);
        };

        txt.text = buttonData.Text;
        button.onClick.AddListener(new UnityEngine.Events.UnityAction(fireAndClose));
    }