Ejemplo n.º 1
0
    public virtual void Show(string alertTitleString_, string confirmationBtnString_, string[] otherBtnStrings_, bool showTitleIcon_)
    {
        if (Application.isEditor && !Application.isPlaying)
        {
            Debug.LogWarning("Show can only be called in play mode");
            return;
        }

        InitializeLabelWithTextSafely(titleLabel, alertTitleString_);
        InitializeSlicedButtonWithTextSafely(confirmationButton, confirmationBtnString_);

        if (otherBtnStrings_ != null && cancelButton != null)
        {
            int buttonIndex_ = 0;
            foreach (string btnTitle_ in  otherBtnStrings_)
            {
                UISlicedImageButton button_ = null;

                if (buttonIndex_ == 0)
                {
                    button_ = cancelButton;
                }

                else                 //make new instance of button
                {
                    GameObject go = NGUITools.AddChild(buttonsGroupTransform.gameObject, cancelButton.gameObject);
                    go.transform.localPosition = cancelButton.transform.localPosition;

                    UIButtonMessage btnMsg = go.AddComponent <UIButtonMessage>();
                    btnMsg.functionName = "OnButton";
                    btnMsg.target       = gameObject;

                    button_ = go.GetComponent <UISlicedImageButton>();
                }

                NGUITools.SetActive(button_.gameObject, true);
                button_.SetTitle(btnTitle_);
                button_.Commit();

                button_.name = buttonIndex_ + ".Other button";
                buttonIndex_++;
            }
        }
        else if (cancelButton != null)
        {
            // there is no cancel button
            NGUITools.SetActive(cancelButton.gameObject, false);
        }

        if (titleIconSprite != null)
        {
            NGUITools.SetActive(titleIconSprite.gameObject, showTitleIcon_);
        }
        Reposition();
        Present();
    }
Ejemplo n.º 2
0
 public void InitializeSlicedButtonWithTextSafely(UISlicedImageButton button, string text)
 {
     if (string.IsNullOrEmpty(text))
     {
         if (button != null)
         {
             NGUITools.SetActive(button.gameObject, false);
         }
     }
     else
     {
         if (button != null)
         {
             NGUITools.SetActive(button.gameObject, true);
             button.SetTitle(text);
             button.Commit();
         }
     }
 }