本贴是自用提示消息窗口,仅供参考。
1.首先要有一个提示消息框的预制体。
2.本框架注意加载资源的地方需要改一下。
MessageBox
sing UnityEngine ;
/// <summary>
/// 通用对话框通用类
/// </summary>
public class MessageBox : MonoBehaviour
{
public delegate void MessageDelegate( System.Object obj);
public MessageDelegate OkClick ;
public MessageDelegate CancelClick ;
private string customTextOK ;
public string TextOK
{
get { return textOK. text; }
set
{
textOK.text = value;
customTextOK = value ;
}
}
private string customTextCancel ;
public string TextCancel
{
get { return textCancel. text; }
set
{
textCancel.text = value;
customTextCancel = value ;
}
}
public int WidthOK
{
get { return widgetOK. width; }
set
{
widgetOK.width = value;
}
}
public int WidthCancel
{
get { return widgetCancel. width; }
set
{
widgetCancel.width = value;
}
}
public string Content
{
get { return content. text; }
set
{
content.text = value;
}
}
public int WitdhContent
{
get { return content. width; }
set
{
content.width = value;
}
}
public int StartingRenderQueue
{
get { return uiPanel. startingRenderQueue; }
set
{
uiPanel.startingRenderQueue = value;
}
}
public UIWidget.Pivot ContentPivot
{
get { return content. pivot; }
set
{
content.pivot = value;
}
}
// 延迟启用确定按钮
private float delayOkTime = 0;
public float DelayOkTime
{
get { return delayOkTime; }
set
{
delayOkTime = value ;
}
}
// 延迟启用取消按钮
private float delayCancelTime = 0;
public float DelayCancelTime
{
get { return delayCancelTime; }
set
{
delayCancelTime = value ;
}
}
public enum Type
{
OK,
OKCancel,
Custom1Btn, // 自定义一个按钮
Custom2Btn, // 自定义两个按钮
};
public Type type { get; private set; }
// 点背景是不是可以关闭对话框
public bool CanCloseByFadeBGClicked = true;
// 点击背景是否关闭对话框,只是关闭,不执行其他
public bool I