Exemplo n.º 1
0
    public void ShowPopup(string heading, string msg, string positiveBtnTxt, string negativeBtnTxt,
                          UnityAction positiveBtnAction, UnityAction negativeBtnAction, UnityAction closeBtnAction)
    {
        if (popup == null)
        {
            popup        = Instantiate(popupPrefab);
            popupHandler = popup.GetComponent <PopupHandler> ();
        }

        if (popupHandler != null)
        {
            popupHandler.SetHeading(heading);
            popupHandler.SetMessage(msg);
            popupHandler.SetPositiveBtnTxt(positiveBtnTxt);
            popupHandler.SetNegativeBtnTxt(negativeBtnTxt);

            if (positiveBtnAction == null)
            {
                popupHandler.HidePositiveBtn();
            }
            else
            {
                popupHandler.SetPositiveBtnAction(positiveBtnAction);
            }

            if (negativeBtnAction == null)
            {
                popupHandler.HideNegativeBtn();
            }
            else
            {
                popupHandler.SetNegativeBtnAction(negativeBtnAction);
            }

            if (closeBtnAction == null)
            {
                popupHandler.HideCloseBtn();
            }
            else
            {
                popupHandler.SetCloseBtnAction(closeBtnAction);
            }

            popupHandler.ShowPopup();
        }
    }