public void InitMsgBox(string msg, MessageBoxType type, MsgBoxCallBack callback) { if (rt == null) { rt = GetComponent <RectTransform> (); } // rt.DOScale(1, 0.5f); rt.gameObject.SetActive(true); btnLeft.SetActive(false); btnCenter.SetActive(false); btnRight.SetActive(false); textMsg.text = msg; this.callback = callback; if (type == MessageBoxType.OK) { SetCenterBtn("确定"); } else if (type == MessageBoxType.OK_Cancle) { SetLeftBtn("确定"); SetRightBtn("取消"); } else if (type == MessageBoxType.OK_Other_Cancle) { SetLeftBtn("确定"); SetCenterBtn("其他"); SetRightBtn("取消"); } }
/// <summary> /// 消息窗口的显示,目前支持3种类型 /// </summary> public void ShowMessageBox(string msg, MessageBoxType type, MsgBoxCallBack callback = null) { string wndPath = wndResDict [WindowID.Msgbox]; GameObject prefab = Resources.Load <GameObject> ("UIPrefab/Msgbox"); if (prefab != null) { GameObject clone = (GameObject)GameObject.Instantiate(prefab); UnityTools.AddChildToTarget(msgBoxRoot.transform, clone.transform); UIMessageBox msgBox = clone.GetComponent <UIMessageBox> (); } }