Ejemplo n.º 1
0
 public void ShowPopUp(string popupText, List <string> ButtonTexts, TypeOfPopUpButtons PopUpButtonType, TypeOfPopUp PopUpType, float Time, Action OnYesPressed, Action OnNoPressed, string Heading = "")
 {
     Popup_Updated.SetupPopUp(popupText, ButtonTexts, PopUpButtonType, PopUpType, Time, OnYesPressed, OnNoPressed, Heading);
     Popup_Updated.gameObject.Show();
 }
Ejemplo n.º 2
0
    //TODO setup popup
    public void SetupPopUp(string popupText, List <string> ButtonTexts, TypeOfPopUpButtons PopUpButtonType, TypeOfPopUp PopUpType, float Time, Action OnYesPressed, Action OnNoPressed, string HeadingText = "")
    {
        Heading.text   = HeadingText;
        PopUpText.text = popupText;
        if (ButtonTexts != null)
        {
            if (ButtonTexts.Count > 0)
            {
                if (ButtonTexts.Count == 2)
                {
                    for (int i = 0; i < Buttons.Count; i++)
                    {
                        if (Buttons[i].ButtonType == PopUpButtons.Yes || Buttons[i].ButtonType == PopUpButtons.Ok)
                        {
                            Buttons[i].ButtonText.text = ButtonTexts[0];
                        }
                        else if (Buttons[i].ButtonType == PopUpButtons.No)
                        {
                            Buttons[i].ButtonText.text = ButtonTexts[1];
                        }
                    }
                }
                else if (ButtonTexts.Count == 1)
                {
                    for (int i = 0; i < Buttons.Count; i++)
                    {
                        if (Buttons[i].ButtonType == PopUpButtons.Yes || Buttons[i].ButtonType == PopUpButtons.Ok)
                        {
                            Buttons[i].ButtonText.text = ButtonTexts[0];
                        }
                    }
                }
            }
        }
        switch (PopUpButtonType)
        {
        case TypeOfPopUpButtons.YesNo:
            for (int i = 0; i < Buttons.Count; i++)
            {
                if (Buttons[i].ButtonType == PopUpButtons.Yes || Buttons[i].ButtonType == PopUpButtons.No)
                {
                    Buttons[i].Button.gameObject.Show();
                    Buttons[i].Button.onClick.RemoveAllListeners();
                    if (Buttons[i].ButtonType == PopUpButtons.Yes)
                    {
                        Buttons[i].Button.onClick.AddListener(YesPressed);
                    }
                    else
                    {
                        Buttons[i].Button.onClick.AddListener(NoPressed);
                    }
                }
                else
                {
                    Buttons[i].Button.gameObject.Hide();
                }
            }
            break;

        case TypeOfPopUpButtons.Ok:
            for (int i = 0; i < Buttons.Count; i++)
            {
                if (Buttons[i].ButtonType == PopUpButtons.Ok)
                {
                    Buttons[i].Button.gameObject.Show();
                    Buttons[i].Button.onClick.RemoveAllListeners();
                    Buttons[i].Button.onClick.AddListener(YesPressed);
                }
                else
                {
                    Buttons[i].Button.gameObject.Hide();
                }
            }
            break;

        default:     //NO BUTTON
            for (int i = 0; i < Buttons.Count; i++)
            {
                Buttons[i].Button.gameObject.Hide();
            }
            break;
        }
        switch (PopUpType)
        {
        case TypeOfPopUp.Buttoned:     // Already showing Buttons
            break;

        case TypeOfPopUp.Evented:     // Nothing to do here
            break;

        case TypeOfPopUp.Timed:
            HideAfterTime = StartCoroutine(HidePopUpInTime(Time));
            break;

        case TypeOfPopUp.TimedAndButtoned:
            break;
        }

        this.OnYesPressed = OnYesPressed;
        this.OnNoPressed  = OnNoPressed;
    }