Beispiel #1
0
    public void SetupDialog(string titleKey, string messageKey,
                            string firstButtonKey, Callback firstBtnCallback, AudioSource firstBtnSound,
                            string secondButtonKey, Callback sencondBtnCallback = default, AudioSource secondButton = default)

    {
        // restore default size
        gameObject.SetSize(this.GetWidth(), _defaultHeight);

        title.AddKey(titleKey, null, DialogManager.TitleStyle);
        message.AddKey(messageKey, null, DialogManager.MessageStyle);

        _firstBtnCallback = firstBtnCallback;
        if (firstBtnSound == default)
        {
            firstBtnSound = SoundHelper.Click;
        }

        _sencondBtnCallback = sencondBtnCallback;
        if (secondButton == default)
        {
            secondButton = SoundHelper.Click;
        }

        if (secondButtonKey == default)
        {
            firstButton.GetGameObject().SetActive(false);
            this.secondButton.GetGameObject().SetActive(false);
            okButton.GetGameObject().SetActive(true);
            okButton.textField.AddKey(firstButtonKey, null, DialogManager.ButtonStyle);
            okButton.ClickButton.clickSound = firstBtnSound;
        }
        else
        {
            okButton.GetGameObject().SetActive(false);
            firstButton.GetGameObject().SetActive(true);
            firstButton.textField.AddKey(firstButtonKey, null, DialogManager.ButtonStyle);
            firstButton.ClickButton.clickSound = firstBtnSound;
            this.secondButton.GetGameObject().SetActive(true);
            this.secondButton.textField.AddKey(secondButtonKey, null, DialogManager.ButtonStyle);
            this.secondButton.ClickButton.clickSound = secondButton;
        }
    }