using CG.Framework; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; /******************************************************************************** *Create By CG *Function 弹窗管理 *********************************************************************************/ namespace CG.UTility { public class PopUpMng { //如果弹窗出现后,不允许射线与场景触发 public static bool _TriAble = true; /// /// 弹窗出现后停留一定时间自动消失 /// /// 弹窗内容 /// 停留时间 public static void PopToast(string content, float stayTime, UIGroup group= UIGroup.Tip) { //GameObject toastPrefab = Resources.Load("PopUpPrefab/ShowToastUIPrefab"); //GameObject parentGeo = GameObject.Find("Canvas"); //if (parentGeo == null) //{ // WDebug.LogError("场景中没找到Canvas画布无法创建弹窗!!"); // return; //} GameObject toastGeo = UI_Manage.Instance.ShowPanel("ShowToastUIPrefab", System.Type.GetType("CG.Framework.UIBase"), group); //Transform toastTran = parentGeo.transform.Find("ShowToastUIPrefab"); //if (toastTran) //{ // toastGeo = toastTran.gameObject; // toastGeo.SetActive(true); //} //else //{ // toastGeo = GameObject.Instantiate(toastPrefab, parentGeo.transform); //} toastGeo.name = "ShowToastUIPrefab"; toastGeo.transform.Find("TxtBG/Text").GetComponent().text = content; toastGeo.transform.SetAsLastSibling(); if (stayTime > 0) GameObject.Destroy(toastGeo, stayTime); } /// /// 弹窗出现后停留一定时间自动消失 /// /// 弹窗内容 /// 停留时间 public static void PopAddAudToast(string content,string audName, float stayTime, UIGroup group = UIGroup.Tip) { GameObject toastGeo = UI_Manage.Instance.ShowPanel("ShowToastUIPrefab", System.Type.GetType("ZXK.GYJQR.ShowToastUIPrefab"), group); toastGeo.name = "ShowToastUIPrefab"; ZXK.GYJQR.ShowToastUIPrefab showToast = null; if (!toastGeo.TryGetComponent(out showToast)) { showToast = toastGeo.AddComponent(); } toastGeo.GetComponent().SetTextAudMsg(content, audName); toastGeo.transform.SetAsLastSibling(); if (stayTime > 0) GameObject.Destroy(toastGeo, stayTime); } /// /// 弹窗出现后需要点击确认按钮后消失 /// /// 弹窗主题 /// 弹窗正文 /// 确认按钮文本 /// 点击确认按钮后触发事件 public static void PopAlert(string titleTxt, string content, string btnTxt, System.Action configBtnEvent) { _TriAble = false; GameObject alertGeo = UI_Manage.Instance.ShowPanel("AlertUIPrefab", null, UIGroup.Tip); //GameObject alertPrefab = Resources.Load("PopUpPrefab/AlertUIPrefab"); //GameObject parentGeo = GameObject.Find("Canvas"); //if (parentGeo == null) //{ // WDebug.LogError("场景中没找到Canvas画布无法创建弹窗!!"); // return; //} //GameObject alertGeo = GameObject.Instantiate(alertPrefab, parentGeo.transform); alertGeo.transform.Find("TitleTxt").GetComponent().text = titleTxt; alertGeo.transform.Find("ContentTxt").GetComponent().text = content; alertGeo.transform.Find("ConfirmBtn/Text").GetComponent().text = btnTxt; alertGeo.transform.Find("ConfirmBtn").GetComponent