Пример #1
0
        protected override void OnOpen(object arg = null)
        {
            base.OnOpen(arg);
            m_arg           = arg as UIMsgBoxArg;
            txtContent.text = m_arg.content;
            string[] btnTexts = m_arg.btnText.Split('|');

            UIUtils.SetChildText(ctlTitle, m_arg.title);
            UIUtils.SetActive(ctlTitle, !string.IsNullOrEmpty(m_arg.title));

            float btnWidth  = 200;
            float btnStartX = (1 - btnTexts.Length) * btnWidth / 2;

            for (int i = 0; i < buttons.Length; i++)
            {
                if (i < btnTexts.Length)
                {
                    UIUtils.SetActive(buttons[i], true);
                    UIUtils.SetButtonText(buttons[i], btnTexts[i]);
                    Vector3 pos = buttons[i].transform.localPosition;
                    pos.x = btnStartX + i * btnWidth;
                    buttons[i].transform.localPosition = pos;
                }
                else
                {
                    UIUtils.SetActive(buttons[i], false);
                }

                UIEventTrigger.Get(buttons[i]).onClickWithObject += OnBtnClick;
            }

            Layer = (UILayerDef.TopWindow);
        }
Пример #2
0
        protected override void OnOpen(object arg = null)
        {
            base.OnOpen(arg);
            m_arg = arg as UIMsgBoxArg;
            if (m_arg == null)
            {
                this.LogError("OnOpen() arg must be not null!");
                return;
            }

            textContent.text = m_arg.content;
            string[] btnTexts = m_arg.btnText.Split('|');

            UIUtils.SetChildText(ctlTitle, m_arg.title);
            UIUtils.SetActive(ctlTitle, !string.IsNullOrEmpty(m_arg.title));

            float btnWidth  = 200;
            float btnStartX = (1 - btnTexts.Length) * btnWidth / 2;

            for (int i = 0; i < buttons.Length; i++)
            {
                if (i < btnTexts.Length)
                {
                    UIUtils.SetButtonText(buttons[i], btnTexts[i]);
                    UIUtils.SetActive(buttons[i], true);
                    Vector3 pos = buttons[i].transform.localPosition;
                    pos.x = btnStartX + i * btnWidth;
                    buttons[i].transform.localPosition = pos;
                }
                else
                {
                    UIUtils.SetActive(buttons[i], false);
                }
            }
        }
Пример #3
0
        protected override void OnOpen(object arg = null)
        {
            base.OnOpen(arg);
            m_arg           = arg as UIMsgBoxArg;
            txtContent.text = m_arg.content;
            string[] btnTexts = m_arg.btnText.Split('|');

            UIUtils.SetChildText(ctlTitle, m_arg.title);
            UIUtils.SetActive(ctlTitle, !string.IsNullOrEmpty(m_arg.title));

            int n = btnTexts.Length;

            if (n == 1)
            {
                UIUtils.SetButtonText(buttons[0], btnTexts[0]);
                UIUtils.SetActive(buttons[0], true);

                Vector3 pos = buttons[0].transform.localPosition;
                pos.x = 0;
                buttons[0].transform.localPosition = pos;

                UIUtils.SetActive(buttons[1], false);
            }
            else if (n > 1)
            {
                for (int i = 0; i < n; i++)
                {
                    UIUtils.SetButtonText(buttons[i], btnTexts[i]);
                    UIUtils.SetActive(buttons[i], true);
                }
            }
        }