コード例 #1
0
        public void OpenSmallMessageBox(string strContent, bool isHaveCancelBtn, enUIEventID confirmID, enUIEventID cancelID, stUIEventParams par, int autoCloseTime = 0, enUIEventID closeTimeID = 0, string confirmStr = "", string cancelStr = "", bool isContentLeftAlign = false)
        {
            CUIFormScript script = Singleton <CUIManager> .GetInstance().OpenForm("UGUI/Form/Common/Form_SmallMessageBox.prefab", false, false);

            if (script != null)
            {
                GameObject gameObject = script.gameObject;
                if (gameObject != null)
                {
                    if (string.IsNullOrEmpty(confirmStr))
                    {
                        confirmStr = Singleton <CTextManager> .GetInstance().GetText("Common_Confirm");
                    }
                    if (string.IsNullOrEmpty(cancelStr))
                    {
                        cancelStr = Singleton <CTextManager> .GetInstance().GetText("Common_Cancel");
                    }
                    GameObject obj3 = gameObject.transform.Find("Panel/Panel/btnGroup/Button_Confirm").gameObject;
                    obj3.GetComponentInChildren <Text>().text = confirmStr;
                    GameObject obj4 = gameObject.transform.Find("Panel/Panel/btnGroup/Button_Cancel").gameObject;
                    obj4.GetComponentInChildren <Text>().text = cancelStr;
                    Text component = gameObject.transform.Find("Panel/Panel/Text").GetComponent <Text>();
                    component.text = strContent;
                    if (!isHaveCancelBtn)
                    {
                        obj4.CustomSetActive(false);
                    }
                    else
                    {
                        obj4.CustomSetActive(true);
                    }
                    CUIEventScript script2 = obj3.GetComponent <CUIEventScript>();
                    CUIEventScript script3 = obj4.GetComponent <CUIEventScript>();
                    script2.SetUIEvent(enUIEventType.Click, confirmID, par);
                    script3.SetUIEvent(enUIEventType.Click, cancelID, par);
                    if (isContentLeftAlign)
                    {
                        component.alignment = TextAnchor.MiddleLeft;
                    }
                    if (autoCloseTime != 0)
                    {
                        Transform transform = script.transform.Find("closeTimer");
                        if (transform != null)
                        {
                            CUITimerScript script4 = transform.GetComponent <CUITimerScript>();
                            if (script4 != null)
                            {
                                if (closeTimeID > enUIEventID.None)
                                {
                                    script4.m_eventIDs[1] = closeTimeID;
                                }
                                script4.SetTotalTime((float)autoCloseTime);
                                script4.StartTimer();
                            }
                        }
                    }
                    this.CloseSendMsgAlert();
                }
            }
        }
コード例 #2
0
        private void OpenInputBoxBase(string title, string inputTip, enUIEventID confirmID, enUIEventID cancelID, stUIEventParams par, string confirmStr = "确定", string cancelStr = "取消")
        {
            CUIFormScript script = Singleton <CUIManager> .GetInstance().OpenForm("UGUI/Form/Common/Form_InputBox.prefab", false, false);

            GameObject gameObject = null;

            if (script != null)
            {
                gameObject = script.gameObject;
            }
            if (gameObject != null)
            {
                GameObject obj3 = gameObject.transform.Find("Panel/btnGroup/Button_Confirm").gameObject;
                obj3.GetComponentInChildren <Text>().text = confirmStr;
                GameObject obj4 = gameObject.transform.Find("Panel/btnGroup/Button_Cancel").gameObject;
                obj4.GetComponentInChildren <Text>().text = cancelStr;
                gameObject.transform.Find("Panel/title/Text").GetComponent <Text>().text            = title;
                gameObject.transform.Find("Panel/inputText/Placeholder").GetComponent <Text>().text = inputTip;
                CUIEventScript component = obj3.GetComponent <CUIEventScript>();
                CUIEventScript script3   = obj4.GetComponent <CUIEventScript>();
                component.SetUIEvent(enUIEventType.Click, confirmID, par);
                script3.SetUIEvent(enUIEventType.Click, cancelID, par);
            }
        }