using CG.Framework;
using DG.Tweening;
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 toastGeo = UI_Manage.Instance.ShowPanel("ShowToastUIPrefab", System.Type.GetType("CG.Framework.UIBase"), group);
toastGeo.name = "ShowToastUIPrefab";
Text textTemp = toastGeo.transform.Find("TxtBG/Text").GetComponent();
if (UtilitiesMng.GetTransCharNum(content) > 68)
{
textTemp.alignment = TextAnchor.MiddleLeft;
}
else
{
textTemp.alignment = TextAnchor.MiddleCenter;
}
textTemp.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";
CG.UTility.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 PopAnswerQuestions(string question, string[] answer, int rightNumber, System.Action configBtnEvent)
{
_TriAble = false;
GameObject alertGeo = UI_Manage.Instance.ShowPanel("AnswerQuestionsPrefab", System.Type.GetType("CG.Framework.UIBase"), UIGroup.Tip);
question = question.Replace("\u0020", "\u00A0");
alertGeo.transform.Find("Mask/Connet/AnswerText").GetComponent().text = question;
Transform answerContain = alertGeo.transform.Find("Mask/Connet/QuestionsConnet");
for (int i = 0; i < answerContain.childCount; i++)
{
if (i < answer.Length)
{
answerContain.GetChild(i).gameObject.SetActive(true);
answerContain.GetChild(i).Find("Text").GetComponent().text = answer[i];
}
else
{
answerContain.GetChild(i).gameObject.SetActive(false);
}
}
alertGeo.transform.Find("Mask/Connet/CloseButton").GetComponent