Beispiel #1
0
    public void Show(string title, string contentName, string content, float w, float h,
                     EventListener.VoidDelegate submitEvent = null,
                     EventListener.VoidDelegate cancelEvent = null,
                     params object[] pars)
    {
        Field.gameObject.SetActive(false);
        LbMsg.gameObject.SetActive(true);
        base.ExcuteInit();

        SubmitEvent    = submitEvent;
        CancelEvent    = cancelEvent;
        PageTitle.text = title;
        EventListener.Get(this.gameObject).onClick = Close;

        this.gameObject.SetActive(true);
        BoxContent.GetComponent <RectTransform>().sizeDelta = new Vector2(w, h);

        if (!string.IsNullOrEmpty(content))
        {
            LbMsg.text = content;
            LbMsg.gameObject.transform.parent.gameObject.SetActive(true);
        }
        else
        {
            LbMsg.gameObject.transform.parent.gameObject.SetActive(false);
        }

        if (!string.IsNullOrEmpty(contentName))
        {
            Transform item = SignalObjectManager.Instance.Spawn(contentName);
            item.parent = Content.transform;
            ContentPage = item.GetComponent <DialogPage>();
            if (pars != null)
            {
                for (int i = 0; i < pars.Length; i++)
                {
                    ContentPage.SetPar(i, pars[i]);
                }
            }
            ContentPage.ExcuteInit();
        }

        if (submitEvent != null)
        {
            EventListener.Get(BtnSubmit.gameObject).onClick = OnSubmit;
        }
        else
        {
            BtnSubmit.gameObject.SetActive(false);
        }
        if (cancelEvent != null)
        {
            EventListener.Get(BtnCancel.gameObject).onClick = OnCancel;
        }
        else
        {
            BtnCancel.gameObject.SetActive(false);
        }
    }